repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ssato/python-anyconfig
src/anyconfig/cli.py
make_parser
def make_parser(defaults=None): """ :param defaults: Default option values """ if defaults is None: defaults = DEFAULTS ctypes = API.list_types() ctypes_s = ", ".join(ctypes) type_help = "Select type of %s config files from " + \ ctypes_s + " [Automatically detected by file ...
python
def make_parser(defaults=None): """ :param defaults: Default option values """ if defaults is None: defaults = DEFAULTS ctypes = API.list_types() ctypes_s = ", ".join(ctypes) type_help = "Select type of %s config files from " + \ ctypes_s + " [Automatically detected by file ...
[ "def", "make_parser", "(", "defaults", "=", "None", ")", ":", "if", "defaults", "is", "None", ":", "defaults", "=", "DEFAULTS", "ctypes", "=", "API", ".", "list_types", "(", ")", "ctypes_s", "=", "\", \"", ".", "join", "(", "ctypes", ")", "type_help", ...
:param defaults: Default option values
[ ":", "param", "defaults", ":", "Default", "option", "values" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L118-L187
ssato/python-anyconfig
src/anyconfig/cli.py
_exit_with_output
def _exit_with_output(content, exit_code=0): """ Exit the program with printing out messages. :param content: content to print out :param exit_code: Exit code """ (sys.stdout if exit_code == 0 else sys.stderr).write(content + os.linesep) sys.exit(exit_code)
python
def _exit_with_output(content, exit_code=0): """ Exit the program with printing out messages. :param content: content to print out :param exit_code: Exit code """ (sys.stdout if exit_code == 0 else sys.stderr).write(content + os.linesep) sys.exit(exit_code)
[ "def", "_exit_with_output", "(", "content", ",", "exit_code", "=", "0", ")", ":", "(", "sys", ".", "stdout", "if", "exit_code", "==", "0", "else", "sys", ".", "stderr", ")", ".", "write", "(", "content", "+", "os", ".", "linesep", ")", "sys", ".", ...
Exit the program with printing out messages. :param content: content to print out :param exit_code: Exit code
[ "Exit", "the", "program", "with", "printing", "out", "messages", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L190-L198
ssato/python-anyconfig
src/anyconfig/cli.py
_show_psrs
def _show_psrs(): """Show list of info of parsers available """ sep = os.linesep types = "Supported types: " + ", ".join(API.list_types()) cids = "IDs: " + ", ".join(c for c, _ps in API.list_by_cid()) x_vs_ps = [" %s: %s" % (x, ", ".join(p.cid() for p in ps)) for x, ps in API.l...
python
def _show_psrs(): """Show list of info of parsers available """ sep = os.linesep types = "Supported types: " + ", ".join(API.list_types()) cids = "IDs: " + ", ".join(c for c, _ps in API.list_by_cid()) x_vs_ps = [" %s: %s" % (x, ", ".join(p.cid() for p in ps)) for x, ps in API.l...
[ "def", "_show_psrs", "(", ")", ":", "sep", "=", "os", ".", "linesep", "types", "=", "\"Supported types: \"", "+", "\", \"", ".", "join", "(", "API", ".", "list_types", "(", ")", ")", "cids", "=", "\"IDs: \"", "+", "\", \"", ".", "join", "(", "c", "fo...
Show list of info of parsers available
[ "Show", "list", "of", "info", "of", "parsers", "available" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L201-L213
ssato/python-anyconfig
src/anyconfig/cli.py
_parse_args
def _parse_args(argv): """ Show supported config format types or usage. :param argv: Argument list to parse or None (sys.argv will be set). :return: argparse.Namespace object or None (exit before return) """ parser = make_parser() args = parser.parse_args(argv) LOGGER.setLevel(to_log_le...
python
def _parse_args(argv): """ Show supported config format types or usage. :param argv: Argument list to parse or None (sys.argv will be set). :return: argparse.Namespace object or None (exit before return) """ parser = make_parser() args = parser.parse_args(argv) LOGGER.setLevel(to_log_le...
[ "def", "_parse_args", "(", "argv", ")", ":", "parser", "=", "make_parser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", "argv", ")", "LOGGER", ".", "setLevel", "(", "to_log_level", "(", "args", ".", "loglevel", ")", ")", "if", "args", ".", ...
Show supported config format types or usage. :param argv: Argument list to parse or None (sys.argv will be set). :return: argparse.Namespace object or None (exit before return)
[ "Show", "supported", "config", "format", "types", "or", "usage", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L216-L244
ssato/python-anyconfig
src/anyconfig/cli.py
_do_get
def _do_get(cnf, get_path): """ :param cnf: Configuration object to print out :param get_path: key path given in --get option :return: updated Configuration object if no error """ (cnf, err) = API.get(cnf, get_path) if cnf is None: # Failed to get the result. _exit_with_output("Fail...
python
def _do_get(cnf, get_path): """ :param cnf: Configuration object to print out :param get_path: key path given in --get option :return: updated Configuration object if no error """ (cnf, err) = API.get(cnf, get_path) if cnf is None: # Failed to get the result. _exit_with_output("Fail...
[ "def", "_do_get", "(", "cnf", ",", "get_path", ")", ":", "(", "cnf", ",", "err", ")", "=", "API", ".", "get", "(", "cnf", ",", "get_path", ")", "if", "cnf", "is", "None", ":", "# Failed to get the result.", "_exit_with_output", "(", "\"Failed to get result...
:param cnf: Configuration object to print out :param get_path: key path given in --get option :return: updated Configuration object if no error
[ ":", "param", "cnf", ":", "Configuration", "object", "to", "print", "out", ":", "param", "get_path", ":", "key", "path", "given", "in", "--", "get", "option", ":", "return", ":", "updated", "Configuration", "object", "if", "no", "error" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L256-L266
ssato/python-anyconfig
src/anyconfig/cli.py
_output_type_by_input_path
def _output_type_by_input_path(inpaths, itype, fmsg): """ :param inpaths: List of input file paths :param itype: Input type or None :param fmsg: message if it cannot detect otype by 'inpath' :return: Output type :: str """ msg = ("Specify inpath and/or outpath type[s] with -I/--itype " ...
python
def _output_type_by_input_path(inpaths, itype, fmsg): """ :param inpaths: List of input file paths :param itype: Input type or None :param fmsg: message if it cannot detect otype by 'inpath' :return: Output type :: str """ msg = ("Specify inpath and/or outpath type[s] with -I/--itype " ...
[ "def", "_output_type_by_input_path", "(", "inpaths", ",", "itype", ",", "fmsg", ")", ":", "msg", "=", "(", "\"Specify inpath and/or outpath type[s] with -I/--itype \"", "\"or -O/--otype option explicitly\"", ")", "if", "itype", "is", "None", ":", "try", ":", "otype", ...
:param inpaths: List of input file paths :param itype: Input type or None :param fmsg: message if it cannot detect otype by 'inpath' :return: Output type :: str
[ ":", "param", "inpaths", ":", "List", "of", "input", "file", "paths", ":", "param", "itype", ":", "Input", "type", "or", "None", ":", "param", "fmsg", ":", "message", "if", "it", "cannot", "detect", "otype", "by", "inpath", ":", "return", ":", "Output"...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L269-L288
ssato/python-anyconfig
src/anyconfig/cli.py
_try_dump
def _try_dump(cnf, outpath, otype, fmsg, extra_opts=None): """ :param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param fmsg: message if it cannot detect otype by 'inpath' :param extra_opts: Map object will be given to API.du...
python
def _try_dump(cnf, outpath, otype, fmsg, extra_opts=None): """ :param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param fmsg: message if it cannot detect otype by 'inpath' :param extra_opts: Map object will be given to API.du...
[ "def", "_try_dump", "(", "cnf", ",", "outpath", ",", "otype", ",", "fmsg", ",", "extra_opts", "=", "None", ")", ":", "if", "extra_opts", "is", "None", ":", "extra_opts", "=", "{", "}", "try", ":", "API", ".", "dump", "(", "cnf", ",", "outpath", ","...
:param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param fmsg: message if it cannot detect otype by 'inpath' :param extra_opts: Map object will be given to API.dump as extra options
[ ":", "param", "cnf", ":", "Configuration", "object", "to", "print", "out", ":", "param", "outpath", ":", "Output", "file", "path", "or", "None", ":", "param", "otype", ":", "Output", "type", "or", "None", ":", "param", "fmsg", ":", "message", "if", "it...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L291-L306
ssato/python-anyconfig
src/anyconfig/cli.py
_output_result
def _output_result(cnf, outpath, otype, inpaths, itype, extra_opts=None): """ :param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param inpaths: List of input file paths :param itype: Input type or None ...
python
def _output_result(cnf, outpath, otype, inpaths, itype, extra_opts=None): """ :param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param inpaths: List of input file paths :param itype: Input type or None ...
[ "def", "_output_result", "(", "cnf", ",", "outpath", ",", "otype", ",", "inpaths", ",", "itype", ",", "extra_opts", "=", "None", ")", ":", "fmsg", "=", "(", "\"Uknown file type and cannot detect appropriate backend \"", "\"from its extension, '%s'\"", ")", "if", "no...
:param cnf: Configuration object to print out :param outpath: Output file path or None :param otype: Output type or None :param inpaths: List of input file paths :param itype: Input type or None :param extra_opts: Map object will be given to API.dump as extra options
[ ":", "param", "cnf", ":", "Configuration", "object", "to", "print", "out", ":", "param", "outpath", ":", "Output", "file", "path", "or", "None", ":", "param", "otype", ":", "Output", "type", "or", "None", ":", "param", "inpaths", ":", "List", "of", "in...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L309-L330
ssato/python-anyconfig
src/anyconfig/cli.py
_load_diff
def _load_diff(args, extra_opts): """ :param args: :class:`argparse.Namespace` object :param extra_opts: Map object given to API.load as extra options """ try: diff = API.load(args.inputs, args.itype, ac_ignore_missing=args.ignore_missing, ac_m...
python
def _load_diff(args, extra_opts): """ :param args: :class:`argparse.Namespace` object :param extra_opts: Map object given to API.load as extra options """ try: diff = API.load(args.inputs, args.itype, ac_ignore_missing=args.ignore_missing, ac_m...
[ "def", "_load_diff", "(", "args", ",", "extra_opts", ")", ":", "try", ":", "diff", "=", "API", ".", "load", "(", "args", ".", "inputs", ",", "args", ".", "itype", ",", "ac_ignore_missing", "=", "args", ".", "ignore_missing", ",", "ac_merge", "=", "args...
:param args: :class:`argparse.Namespace` object :param extra_opts: Map object given to API.load as extra options
[ ":", "param", "args", ":", ":", "class", ":", "argparse", ".", "Namespace", "object", ":", "param", "extra_opts", ":", "Map", "object", "given", "to", "API", ".", "load", "as", "extra", "options" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L333-L353
ssato/python-anyconfig
src/anyconfig/cli.py
_do_filter
def _do_filter(cnf, args): """ :param cnf: Mapping object represents configuration data :param args: :class:`argparse.Namespace` object :return: 'cnf' may be updated """ if args.query: cnf = API.query(cnf, args.query) elif args.get: cnf = _do_get(cnf, args.get) elif args....
python
def _do_filter(cnf, args): """ :param cnf: Mapping object represents configuration data :param args: :class:`argparse.Namespace` object :return: 'cnf' may be updated """ if args.query: cnf = API.query(cnf, args.query) elif args.get: cnf = _do_get(cnf, args.get) elif args....
[ "def", "_do_filter", "(", "cnf", ",", "args", ")", ":", "if", "args", ".", "query", ":", "cnf", "=", "API", ".", "query", "(", "cnf", ",", "args", ".", "query", ")", "elif", "args", ".", "get", ":", "cnf", "=", "_do_get", "(", "cnf", ",", "args...
:param cnf: Mapping object represents configuration data :param args: :class:`argparse.Namespace` object :return: 'cnf' may be updated
[ ":", "param", "cnf", ":", "Mapping", "object", "represents", "configuration", "data", ":", "param", "args", ":", ":", "class", ":", "argparse", ".", "Namespace", "object", ":", "return", ":", "cnf", "may", "be", "updated" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L356-L370
ssato/python-anyconfig
src/anyconfig/cli.py
main
def main(argv=None): """ :param argv: Argument list to parse or None (sys.argv will be set). """ args = _parse_args((argv if argv else sys.argv)[1:]) cnf = os.environ.copy() if args.env else {} extra_opts = dict() if args.extra_opts: extra_opts = anyconfig.parser.parse(args.extra_op...
python
def main(argv=None): """ :param argv: Argument list to parse or None (sys.argv will be set). """ args = _parse_args((argv if argv else sys.argv)[1:]) cnf = os.environ.copy() if args.env else {} extra_opts = dict() if args.extra_opts: extra_opts = anyconfig.parser.parse(args.extra_op...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "args", "=", "_parse_args", "(", "(", "argv", "if", "argv", "else", "sys", ".", "argv", ")", "[", "1", ":", "]", ")", "cnf", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "args", "....
:param argv: Argument list to parse or None (sys.argv will be set).
[ ":", "param", "argv", ":", "Argument", "list", "to", "parse", "or", "None", "(", "sys", ".", "argv", "will", "be", "set", ")", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L373-L400
ssato/python-anyconfig
src/anyconfig/schema.py
_validate_all
def _validate_all(data, schema): """ See the descritpion of :func:`validate` for more details of parameters and return value. :seealso: https://python-jsonschema.readthedocs.io/en/latest/validate/, a section of 'iter_errors' especially """ vldtr = jsonschema.Draft4Validator(schema) # :rais...
python
def _validate_all(data, schema): """ See the descritpion of :func:`validate` for more details of parameters and return value. :seealso: https://python-jsonschema.readthedocs.io/en/latest/validate/, a section of 'iter_errors' especially """ vldtr = jsonschema.Draft4Validator(schema) # :rais...
[ "def", "_validate_all", "(", "data", ",", "schema", ")", ":", "vldtr", "=", "jsonschema", ".", "Draft4Validator", "(", "schema", ")", "# :raises: SchemaError, ...", "errors", "=", "list", "(", "vldtr", ".", "iter_errors", "(", "data", ")", ")", "return", "("...
See the descritpion of :func:`validate` for more details of parameters and return value. :seealso: https://python-jsonschema.readthedocs.io/en/latest/validate/, a section of 'iter_errors' especially
[ "See", "the", "descritpion", "of", ":", "func", ":", "validate", "for", "more", "details", "of", "parameters", "and", "return", "value", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L51-L62
ssato/python-anyconfig
src/anyconfig/schema.py
_validate
def _validate(data, schema, ac_schema_safe=True, **options): """ See the descritpion of :func:`validate` for more details of parameters and return value. Validate target object 'data' with given schema object. """ try: jsonschema.validate(data, schema, **options) except (jsonschema...
python
def _validate(data, schema, ac_schema_safe=True, **options): """ See the descritpion of :func:`validate` for more details of parameters and return value. Validate target object 'data' with given schema object. """ try: jsonschema.validate(data, schema, **options) except (jsonschema...
[ "def", "_validate", "(", "data", ",", "schema", ",", "ac_schema_safe", "=", "True", ",", "*", "*", "options", ")", ":", "try", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ",", "*", "*", "options", ")", "except", "(", "jsonschema", ...
See the descritpion of :func:`validate` for more details of parameters and return value. Validate target object 'data' with given schema object.
[ "See", "the", "descritpion", "of", ":", "func", ":", "validate", "for", "more", "details", "of", "parameters", "and", "return", "value", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L65-L81
ssato/python-anyconfig
src/anyconfig/schema.py
validate
def validate(data, schema, ac_schema_safe=True, ac_schema_errors=False, **options): """ Validate target object with given schema object, loaded from JSON schema. See also: https://python-jsonschema.readthedocs.org/en/latest/validate/ :parae data: Target object (a dict or a dict-like objec...
python
def validate(data, schema, ac_schema_safe=True, ac_schema_errors=False, **options): """ Validate target object with given schema object, loaded from JSON schema. See also: https://python-jsonschema.readthedocs.org/en/latest/validate/ :parae data: Target object (a dict or a dict-like objec...
[ "def", "validate", "(", "data", ",", "schema", ",", "ac_schema_safe", "=", "True", ",", "ac_schema_errors", "=", "False", ",", "*", "*", "options", ")", ":", "if", "not", "JSONSCHEMA_IS_AVAIL", ":", "return", "(", "True", ",", "_NA_MSG", ")", "options", ...
Validate target object with given schema object, loaded from JSON schema. See also: https://python-jsonschema.readthedocs.org/en/latest/validate/ :parae data: Target object (a dict or a dict-like object) to validate :param schema: Schema object (a dict or a dict-like object) instantiated from sche...
[ "Validate", "target", "object", "with", "given", "schema", "object", "loaded", "from", "JSON", "schema", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L84-L113
ssato/python-anyconfig
src/anyconfig/schema.py
array_to_schema
def array_to_schema(arr, **options): """ Generate a JSON schema object with type annotation added for given object. :param arr: Array of mapping objects like dicts :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is needed - ac_sch...
python
def array_to_schema(arr, **options): """ Generate a JSON schema object with type annotation added for given object. :param arr: Array of mapping objects like dicts :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is needed - ac_sch...
[ "def", "array_to_schema", "(", "arr", ",", "*", "*", "options", ")", ":", "(", "typemap", ",", "strict", ")", "=", "_process_options", "(", "*", "*", "options", ")", "arr", "=", "list", "(", "arr", ")", "scm", "=", "dict", "(", "type", "=", "typema...
Generate a JSON schema object with type annotation added for given object. :param arr: Array of mapping objects like dicts :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is needed - ac_schema_typemap: Type to JSON schema type mappings ...
[ "Generate", "a", "JSON", "schema", "object", "with", "type", "annotation", "added", "for", "given", "object", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L126-L148
ssato/python-anyconfig
src/anyconfig/schema.py
object_to_schema
def object_to_schema(obj, **options): """ Generate a node represents JSON schema object with type annotation added for given object node. :param obj: mapping object such like a dict :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is n...
python
def object_to_schema(obj, **options): """ Generate a node represents JSON schema object with type annotation added for given object node. :param obj: mapping object such like a dict :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is n...
[ "def", "object_to_schema", "(", "obj", ",", "*", "*", "options", ")", ":", "(", "typemap", ",", "strict", ")", "=", "_process_options", "(", "*", "*", "options", ")", "props", "=", "dict", "(", "(", "k", ",", "gen_schema", "(", "v", ",", "*", "*", ...
Generate a node represents JSON schema object with type annotation added for given object node. :param obj: mapping object such like a dict :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is needed - ac_schema_typemap: Type to JSON sc...
[ "Generate", "a", "node", "represents", "JSON", "schema", "object", "with", "type", "annotation", "added", "for", "given", "object", "node", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L151-L171
ssato/python-anyconfig
src/anyconfig/schema.py
gen_schema
def gen_schema(data, **options): """ Generate a node represents JSON schema object with type annotation added for given object node. :param data: Configuration data object (dict[-like] or namedtuple) :param options: Other keyword options such as: - ac_schema_strict: True if more strict (pr...
python
def gen_schema(data, **options): """ Generate a node represents JSON schema object with type annotation added for given object node. :param data: Configuration data object (dict[-like] or namedtuple) :param options: Other keyword options such as: - ac_schema_strict: True if more strict (pr...
[ "def", "gen_schema", "(", "data", ",", "*", "*", "options", ")", ":", "if", "data", "is", "None", ":", "return", "dict", "(", "type", "=", "\"null\"", ")", "_type", "=", "type", "(", "data", ")", "if", "_type", "in", "_SIMPLE_TYPES", ":", "typemap", ...
Generate a node represents JSON schema object with type annotation added for given object node. :param data: Configuration data object (dict[-like] or namedtuple) :param options: Other keyword options such as: - ac_schema_strict: True if more strict (precise) schema is needed - ac_schema_t...
[ "Generate", "a", "node", "represents", "JSON", "schema", "object", "with", "type", "annotation", "added", "for", "given", "object", "node", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L174-L202
ssato/python-anyconfig
src/anyconfig/backend/base.py
ensure_outdir_exists
def ensure_outdir_exists(filepath): """ Make dir to dump 'filepath' if that dir does not exist. :param filepath: path of file to dump """ outdir = os.path.dirname(filepath) if outdir and not os.path.exists(outdir): LOGGER.debug("Making output dir: %s", outdir) os.makedirs(outdi...
python
def ensure_outdir_exists(filepath): """ Make dir to dump 'filepath' if that dir does not exist. :param filepath: path of file to dump """ outdir = os.path.dirname(filepath) if outdir and not os.path.exists(outdir): LOGGER.debug("Making output dir: %s", outdir) os.makedirs(outdi...
[ "def", "ensure_outdir_exists", "(", "filepath", ")", ":", "outdir", "=", "os", ".", "path", ".", "dirname", "(", "filepath", ")", "if", "outdir", "and", "not", "os", ".", "path", ".", "exists", "(", "outdir", ")", ":", "LOGGER", ".", "debug", "(", "\...
Make dir to dump 'filepath' if that dir does not exist. :param filepath: path of file to dump
[ "Make", "dir", "to", "dump", "filepath", "if", "that", "dir", "does", "not", "exist", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L63-L73
ssato/python-anyconfig
src/anyconfig/backend/base.py
to_method
def to_method(func): """ Lift :func:`func` to a method; it will be called with the first argument 'self' ignored. :param func: Any callable object """ @functools.wraps(func) def wrapper(*args, **kwargs): """Wrapper function. """ return func(*args[1:], **kwargs) ...
python
def to_method(func): """ Lift :func:`func` to a method; it will be called with the first argument 'self' ignored. :param func: Any callable object """ @functools.wraps(func) def wrapper(*args, **kwargs): """Wrapper function. """ return func(*args[1:], **kwargs) ...
[ "def", "to_method", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapper function.\n \"\"\"", "return", "func", "(", "*", "args", "[", "1", ...
Lift :func:`func` to a method; it will be called with the first argument 'self' ignored. :param func: Any callable object
[ "Lift", ":", "func", ":", "func", "to", "a", "method", ";", "it", "will", "be", "called", "with", "the", "first", "argument", "self", "ignored", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L76-L89
ssato/python-anyconfig
src/anyconfig/backend/base.py
load_with_fn
def load_with_fn(load_fn, content_or_strm, container, allow_primitives=False, **options): """ Load data from given string or stream 'content_or_strm'. :param load_fn: Callable to load data :param content_or_strm: data content or stream provides it :param container: callble to make ...
python
def load_with_fn(load_fn, content_or_strm, container, allow_primitives=False, **options): """ Load data from given string or stream 'content_or_strm'. :param load_fn: Callable to load data :param content_or_strm: data content or stream provides it :param container: callble to make ...
[ "def", "load_with_fn", "(", "load_fn", ",", "content_or_strm", ",", "container", ",", "allow_primitives", "=", "False", ",", "*", "*", "options", ")", ":", "ret", "=", "load_fn", "(", "content_or_strm", ",", "*", "*", "options", ")", "if", "anyconfig", "."...
Load data from given string or stream 'content_or_strm'. :param load_fn: Callable to load data :param content_or_strm: data content or stream provides it :param container: callble to make a container object :param allow_primitives: True if the parser.load* may return objects of primitive data t...
[ "Load", "data", "from", "given", "string", "or", "stream", "content_or_strm", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L555-L574
ssato/python-anyconfig
src/anyconfig/backend/base.py
dump_with_fn
def dump_with_fn(dump_fn, data, stream, **options): """ Dump 'data' to a string if 'stream' is None, or dump 'data' to a file or file-like object 'stream'. :param dump_fn: Callable to dump data :param data: Data to dump :param stream: File or file like object or None :param options: option...
python
def dump_with_fn(dump_fn, data, stream, **options): """ Dump 'data' to a string if 'stream' is None, or dump 'data' to a file or file-like object 'stream'. :param dump_fn: Callable to dump data :param data: Data to dump :param stream: File or file like object or None :param options: option...
[ "def", "dump_with_fn", "(", "dump_fn", ",", "data", ",", "stream", ",", "*", "*", "options", ")", ":", "if", "stream", "is", "None", ":", "return", "dump_fn", "(", "data", ",", "*", "*", "options", ")", "return", "dump_fn", "(", "data", ",", "stream"...
Dump 'data' to a string if 'stream' is None, or dump 'data' to a file or file-like object 'stream'. :param dump_fn: Callable to dump data :param data: Data to dump :param stream: File or file like object or None :param options: optional keyword parameters :return: String represents data if st...
[ "Dump", "data", "to", "a", "string", "if", "stream", "is", "None", "or", "dump", "data", "to", "a", "file", "or", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L577-L592
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin._container_factory
def _container_factory(self, **options): """ The order of prirorities are ac_dict, backend specific dict class option, ac_ordered. :param options: Keyword options may contain 'ac_ordered'. :return: Factory (class or function) to make an container. """ ac_dict = o...
python
def _container_factory(self, **options): """ The order of prirorities are ac_dict, backend specific dict class option, ac_ordered. :param options: Keyword options may contain 'ac_ordered'. :return: Factory (class or function) to make an container. """ ac_dict = o...
[ "def", "_container_factory", "(", "self", ",", "*", "*", "options", ")", ":", "ac_dict", "=", "options", ".", "get", "(", "\"ac_dict\"", ",", "False", ")", "_dicts", "=", "[", "x", "for", "x", "in", "(", "options", ".", "get", "(", "o", ")", "for",...
The order of prirorities are ac_dict, backend specific dict class option, ac_ordered. :param options: Keyword options may contain 'ac_ordered'. :return: Factory (class or function) to make an container.
[ "The", "order", "of", "prirorities", "are", "ac_dict", "backend", "specific", "dict", "class", "option", "ac_ordered", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L175-L194
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin._load_options
def _load_options(self, container, **options): """ Select backend specific loading options. """ # Force set dict option if available in backend. For example, # options["object_hook"] will be OrderedDict if 'container' was # OrderedDict in JSON backend. for opt in ...
python
def _load_options(self, container, **options): """ Select backend specific loading options. """ # Force set dict option if available in backend. For example, # options["object_hook"] will be OrderedDict if 'container' was # OrderedDict in JSON backend. for opt in ...
[ "def", "_load_options", "(", "self", ",", "container", ",", "*", "*", "options", ")", ":", "# Force set dict option if available in backend. For example,", "# options[\"object_hook\"] will be OrderedDict if 'container' was", "# OrderedDict in JSON backend.", "for", "opt", "in", "...
Select backend specific loading options.
[ "Select", "backend", "specific", "loading", "options", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L196-L206
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin.load_from_string
def load_from_string(self, content, container, **kwargs): """ Load config from given string 'content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :re...
python
def load_from_string(self, content, container, **kwargs): """ Load config from given string 'content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :re...
[ "def", "load_from_string", "(", "self", ",", "content", ",", "container", ",", "*", "*", "kwargs", ")", ":", "_not_implemented", "(", "self", ",", "content", ",", "container", ",", "*", "*", "kwargs", ")" ]
Load config from given string 'content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "string", "content", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L208-L218
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin.load_from_path
def load_from_path(self, filepath, container, **kwargs): """ Load config from given file path 'filepath`. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :ret...
python
def load_from_path(self, filepath, container, **kwargs): """ Load config from given file path 'filepath`. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :ret...
[ "def", "load_from_path", "(", "self", ",", "filepath", ",", "container", ",", "*", "*", "kwargs", ")", ":", "_not_implemented", "(", "self", ",", "filepath", ",", "container", ",", "*", "*", "kwargs", ")" ]
Load config from given file path 'filepath`. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "file", "path", "filepath", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L220-L230
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin.load_from_stream
def load_from_stream(self, stream, container, **kwargs): """ Load config from given file like object 'stream`. :param stream: Config file or file like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized ::...
python
def load_from_stream(self, stream, container, **kwargs): """ Load config from given file like object 'stream`. :param stream: Config file or file like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized ::...
[ "def", "load_from_stream", "(", "self", ",", "stream", ",", "container", ",", "*", "*", "kwargs", ")", ":", "_not_implemented", "(", "self", ",", "stream", ",", "container", ",", "*", "*", "kwargs", ")" ]
Load config from given file like object 'stream`. :param stream: Config file or file like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "file", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L232-L242
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin.loads
def loads(self, content, **options): """ Load config from given string 'content' after some checks. :param content: Config file content :param options: options will be passed to backend specific loading functions. please note that options have to be sanitized w/...
python
def loads(self, content, **options): """ Load config from given string 'content' after some checks. :param content: Config file content :param options: options will be passed to backend specific loading functions. please note that options have to be sanitized w/...
[ "def", "loads", "(", "self", ",", "content", ",", "*", "*", "options", ")", ":", "container", "=", "self", ".", "_container_factory", "(", "*", "*", "options", ")", "if", "not", "content", "or", "content", "is", "None", ":", "return", "container", "(",...
Load config from given string 'content' after some checks. :param content: Config file content :param options: options will be passed to backend specific loading functions. please note that options have to be sanitized w/ :func:`anyconfig.utils.filter_options` later...
[ "Load", "config", "from", "given", "string", "content", "after", "some", "checks", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L244-L262
ssato/python-anyconfig
src/anyconfig/backend/base.py
LoaderMixin.load
def load(self, ioi, ac_ignore_missing=False, **options): """ Load config from a file path or a file / file-like object which 'ioi' refering after some checks. :param ioi: 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load d...
python
def load(self, ioi, ac_ignore_missing=False, **options): """ Load config from a file path or a file / file-like object which 'ioi' refering after some checks. :param ioi: 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load d...
[ "def", "load", "(", "self", ",", "ioi", ",", "ac_ignore_missing", "=", "False", ",", "*", "*", "options", ")", ":", "container", "=", "self", ".", "_container_factory", "(", "*", "*", "options", ")", "options", "=", "self", ".", "_load_options", "(", "...
Load config from a file path or a file / file-like object which 'ioi' refering after some checks. :param ioi: 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load data from :param ac_ignore_missing: Ignore and just retur...
[ "Load", "config", "from", "a", "file", "path", "or", "a", "file", "/", "file", "-", "like", "object", "which", "ioi", "refering", "after", "some", "checks", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L264-L298
ssato/python-anyconfig
src/anyconfig/backend/base.py
DumperMixin.dump_to_path
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ _not_implemented(self, cnf...
python
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ _not_implemented(self, cnf...
[ "def", "dump_to_path", "(", "self", ",", "cnf", ",", "filepath", ",", "*", "*", "kwargs", ")", ":", "_not_implemented", "(", "self", ",", "cnf", ",", "filepath", ",", "*", "*", "kwargs", ")" ]
Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "filepath", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L328-L336
ssato/python-anyconfig
src/anyconfig/backend/base.py
DumperMixin.dump_to_stream
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
python
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "_not_implemented", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")" ]
Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L338-L348
ssato/python-anyconfig
src/anyconfig/backend/base.py
DumperMixin.dumps
def dumps(self, cnf, **kwargs): """ Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: string represents the configuration """ kwargs = anyconfig.utils.filter_options(...
python
def dumps(self, cnf, **kwargs): """ Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: string represents the configuration """ kwargs = anyconfig.utils.filter_options(...
[ "def", "dumps", "(", "self", ",", "cnf", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "anyconfig", ".", "utils", ".", "filter_options", "(", "self", ".", "_dump_opts", ",", "kwargs", ")", "return", "self", ".", "dump_to_string", "(", "cnf", ",", ...
Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: string represents the configuration
[ "Dump", "config", "cnf", "to", "a", "string", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L350-L360
ssato/python-anyconfig
src/anyconfig/backend/base.py
DumperMixin.dump
def dump(self, cnf, ioi, **kwargs): """ Dump config 'cnf' to output object of which 'ioi' refering. :param cnf: Configuration data to dump :param ioi: an 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load data from ...
python
def dump(self, cnf, ioi, **kwargs): """ Dump config 'cnf' to output object of which 'ioi' refering. :param cnf: Configuration data to dump :param ioi: an 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load data from ...
[ "def", "dump", "(", "self", ",", "cnf", ",", "ioi", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "anyconfig", ".", "utils", ".", "filter_options", "(", "self", ".", "_dump_opts", ",", "kwargs", ")", "if", "anyconfig", ".", "utils", ".", "is_stre...
Dump config 'cnf' to output object of which 'ioi' refering. :param cnf: Configuration data to dump :param ioi: an 'anyconfig.globals.IOInfo' namedtuple object provides various info of input object to load data from :param kwargs: optional keyword parameters to be saniti...
[ "Dump", "config", "cnf", "to", "output", "object", "of", "which", "ioi", "refering", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L362-L380
ssato/python-anyconfig
src/anyconfig/backend/base.py
FromStringLoaderMixin.load_from_stream
def load_from_stream(self, stream, container, **kwargs): """ Load config from given stream 'stream'. :param stream: Config file or file-like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict ...
python
def load_from_stream(self, stream, container, **kwargs): """ Load config from given stream 'stream'. :param stream: Config file or file-like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict ...
[ "def", "load_from_stream", "(", "self", ",", "stream", ",", "container", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "load_from_string", "(", "stream", ".", "read", "(", ")", ",", "container", ",", "*", "*", "kwargs", ")" ]
Load config from given stream 'stream'. :param stream: Config file or file-like object :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "stream", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L407-L417
ssato/python-anyconfig
src/anyconfig/backend/base.py
FromStringLoaderMixin.load_from_path
def load_from_path(self, filepath, container, **kwargs): """ Load config from given file path 'filepath'. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :ret...
python
def load_from_path(self, filepath, container, **kwargs): """ Load config from given file path 'filepath'. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :ret...
[ "def", "load_from_path", "(", "self", ",", "filepath", ",", "container", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "ropen", "(", "filepath", ")", "as", "inp", ":", "return", "self", ".", "load_from_stream", "(", "inp", ",", "container", "...
Load config from given file path 'filepath'. :param filepath: Config file path :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "file", "path", "filepath", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L419-L430
ssato/python-anyconfig
src/anyconfig/backend/base.py
FromStreamLoaderMixin.load_from_string
def load_from_string(self, content, container, **kwargs): """ Load config from given string 'cnf_content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict ...
python
def load_from_string(self, content, container, **kwargs): """ Load config from given string 'cnf_content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict ...
[ "def", "load_from_string", "(", "self", ",", "content", ",", "container", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "load_from_stream", "(", "anyconfig", ".", "compat", ".", "StringIO", "(", "content", ")", ",", "container", ",", "*", "*"...
Load config from given string 'cnf_content'. :param content: Config content string :param container: callble to make a container object later :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Load", "config", "from", "given", "string", "cnf_content", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L441-L452
ssato/python-anyconfig
src/anyconfig/backend/base.py
ToStringDumperMixin.dump_to_path
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ with self.wopen(filepath) ...
python
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ with self.wopen(filepath) ...
[ "def", "dump_to_path", "(", "self", ",", "cnf", ",", "filepath", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "wopen", "(", "filepath", ")", "as", "out", ":", "out", ".", "write", "(", "self", ".", "dump_to_string", "(", "cnf", ",", "*",...
Dump config 'cnf' to a file 'filepath'. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "filepath", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L477-L486
ssato/python-anyconfig
src/anyconfig/backend/base.py
ToStringDumperMixin.dump_to_stream
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
python
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "stream", ".", "write", "(", "self", ".", "dump_to_string", "(", "cnf", ",", "*", "*", "kwargs", ")", ")" ]
Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L488-L498
ssato/python-anyconfig
src/anyconfig/backend/base.py
ToStreamDumperMixin.dump_to_string
def dump_to_string(self, cnf, **kwargs): """ Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters """ stream = anyconfig.compa...
python
def dump_to_string(self, cnf, **kwargs): """ Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters """ stream = anyconfig.compa...
[ "def", "dump_to_string", "(", "self", ",", "cnf", ",", "*", "*", "kwargs", ")", ":", "stream", "=", "anyconfig", ".", "compat", ".", "StringIO", "(", ")", "self", ".", "dump_to_stream", "(", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", "return...
Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters
[ "Dump", "config", "cnf", "to", "a", "string", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L510-L521
ssato/python-anyconfig
src/anyconfig/backend/base.py
ToStreamDumperMixin.dump_to_path
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath`. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ with self.wopen(filepath) ...
python
def dump_to_path(self, cnf, filepath, **kwargs): """ Dump config 'cnf' to a file 'filepath`. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict """ with self.wopen(filepath) ...
[ "def", "dump_to_path", "(", "self", ",", "cnf", ",", "filepath", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "wopen", "(", "filepath", ")", "as", "out", ":", "self", ".", "dump_to_stream", "(", "cnf", ",", "out", ",", "*", "*", "kwargs"...
Dump config 'cnf' to a file 'filepath`. :param cnf: Configuration data to dump :param filepath: Config file path :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "filepath", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L523-L532
ssato/python-anyconfig
src/anyconfig/backend/base.py
StringStreamFnParser.load_from_string
def load_from_string(self, content, container, **options): """ Load configuration data from given string 'content'. :param content: Configuration string :param container: callble to make a container object :param options: keyword options passed to '_load_from_string_fn' ...
python
def load_from_string(self, content, container, **options): """ Load configuration data from given string 'content'. :param content: Configuration string :param container: callble to make a container object :param options: keyword options passed to '_load_from_string_fn' ...
[ "def", "load_from_string", "(", "self", ",", "content", ",", "container", ",", "*", "*", "options", ")", ":", "return", "load_with_fn", "(", "self", ".", "_load_from_string_fn", ",", "content", ",", "container", ",", "allow_primitives", "=", "self", ".", "al...
Load configuration data from given string 'content'. :param content: Configuration string :param container: callble to make a container object :param options: keyword options passed to '_load_from_string_fn' :return: container object holding the configuration data
[ "Load", "configuration", "data", "from", "given", "string", "content", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L618-L630
ssato/python-anyconfig
src/anyconfig/backend/base.py
StringStreamFnParser.load_from_stream
def load_from_stream(self, stream, container, **options): """ Load data from given stream 'stream'. :param stream: Stream provides configuration data :param container: callble to make a container object :param options: keyword options passed to '_load_from_stream_fn' :r...
python
def load_from_stream(self, stream, container, **options): """ Load data from given stream 'stream'. :param stream: Stream provides configuration data :param container: callble to make a container object :param options: keyword options passed to '_load_from_stream_fn' :r...
[ "def", "load_from_stream", "(", "self", ",", "stream", ",", "container", ",", "*", "*", "options", ")", ":", "return", "load_with_fn", "(", "self", ".", "_load_from_stream_fn", ",", "stream", ",", "container", ",", "allow_primitives", "=", "self", ".", "allo...
Load data from given stream 'stream'. :param stream: Stream provides configuration data :param container: callble to make a container object :param options: keyword options passed to '_load_from_stream_fn' :return: container object holding the configuration data
[ "Load", "data", "from", "given", "stream", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L632-L644
ssato/python-anyconfig
src/anyconfig/backend/base.py
StringStreamFnParser.dump_to_stream
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
python
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: option...
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "dump_with_fn", "(", "self", ".", "_dump_to_stream_fn", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")" ]
Dump config 'cnf' to a file-like object 'stream'. TODO: How to process socket objects same as file objects ? :param cnf: Configuration data to dump :param stream: Config file or file like object :param kwargs: optional keyword parameters to be sanitized :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/base.py#L657-L667
ssato/python-anyconfig
src/anyconfig/ioinfo.py
guess_io_type
def guess_io_type(obj): """Guess input or output type of 'obj'. :param obj: a path string, a pathlib.Path or a file / file-like object :return: IOInfo type defined in anyconfig.globals.IOI_TYPES >>> apath = "/path/to/a_conf.ext" >>> assert guess_io_type(apath) == IOI_PATH_STR >>> from anyconf...
python
def guess_io_type(obj): """Guess input or output type of 'obj'. :param obj: a path string, a pathlib.Path or a file / file-like object :return: IOInfo type defined in anyconfig.globals.IOI_TYPES >>> apath = "/path/to/a_conf.ext" >>> assert guess_io_type(apath) == IOI_PATH_STR >>> from anyconf...
[ "def", "guess_io_type", "(", "obj", ")", ":", "if", "obj", "is", "None", ":", "return", "IOI_NONE", "if", "anyconfig", ".", "utils", ".", "is_path", "(", "obj", ")", ":", "return", "IOI_PATH_STR", "if", "anyconfig", ".", "utils", ".", "is_path_obj", "(",...
Guess input or output type of 'obj'. :param obj: a path string, a pathlib.Path or a file / file-like object :return: IOInfo type defined in anyconfig.globals.IOI_TYPES >>> apath = "/path/to/a_conf.ext" >>> assert guess_io_type(apath) == IOI_PATH_STR >>> from anyconfig.compat import pathlib >>...
[ "Guess", "input", "or", "output", "type", "of", "obj", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/ioinfo.py#L23-L50
ssato/python-anyconfig
src/anyconfig/ioinfo.py
inspect_io_obj
def inspect_io_obj(obj): """ :param obj: a path string, a pathlib.Path or a file / file-like object :return: A tuple of (objtype, objpath, objopener) :raises: UnknownFileTypeError """ itype = guess_io_type(obj) if itype == IOI_PATH_STR: ipath = anyconfig.utils.normpath(obj) ...
python
def inspect_io_obj(obj): """ :param obj: a path string, a pathlib.Path or a file / file-like object :return: A tuple of (objtype, objpath, objopener) :raises: UnknownFileTypeError """ itype = guess_io_type(obj) if itype == IOI_PATH_STR: ipath = anyconfig.utils.normpath(obj) ...
[ "def", "inspect_io_obj", "(", "obj", ")", ":", "itype", "=", "guess_io_type", "(", "obj", ")", "if", "itype", "==", "IOI_PATH_STR", ":", "ipath", "=", "anyconfig", ".", "utils", ".", "normpath", "(", "obj", ")", "ext", "=", "anyconfig", ".", "utils", "...
:param obj: a path string, a pathlib.Path or a file / file-like object :return: A tuple of (objtype, objpath, objopener) :raises: UnknownFileTypeError
[ ":", "param", "obj", ":", "a", "path", "string", "a", "pathlib", ".", "Path", "or", "a", "file", "/", "file", "-", "like", "object" ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/ioinfo.py#L53-L80
ssato/python-anyconfig
src/anyconfig/ioinfo.py
make
def make(obj): """ :param obj: a path string, a pathlib.Path or a file / file-like object :return: Namedtuple object represents a kind of input object such as a file / file-like object, path string or pathlib.Path object :raises: ValueError, UnknownProcessorTypeError, UnknownFileTypeErr...
python
def make(obj): """ :param obj: a path string, a pathlib.Path or a file / file-like object :return: Namedtuple object represents a kind of input object such as a file / file-like object, path string or pathlib.Path object :raises: ValueError, UnknownProcessorTypeError, UnknownFileTypeErr...
[ "def", "make", "(", "obj", ")", ":", "if", "anyconfig", ".", "utils", ".", "is_ioinfo", "(", "obj", ")", ":", "return", "obj", "(", "itype", ",", "ipath", ",", "opener", ",", "ext", ")", "=", "inspect_io_obj", "(", "obj", ")", "return", "IOInfo", "...
:param obj: a path string, a pathlib.Path or a file / file-like object :return: Namedtuple object represents a kind of input object such as a file / file-like object, path string or pathlib.Path object :raises: ValueError, UnknownProcessorTypeError, UnknownFileTypeError
[ ":", "param", "obj", ":", "a", "path", "string", "a", "pathlib", ".", "Path", "or", "a", "file", "/", "file", "-", "like", "object", ":", "return", ":", "Namedtuple", "object", "represents", "a", "kind", "of", "input", "object", "such", "as", "a", "f...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/ioinfo.py#L83-L97
ssato/python-anyconfig
src/anyconfig/backend/shellvars.py
_parseline
def _parseline(line): """ Parse a line contains shell variable definition. :param line: A string to parse, must not start with '#' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline("aaa=") ('aaa', '') >>> _parseline("aaa=bbb") ('aaa', 'bbb') ...
python
def _parseline(line): """ Parse a line contains shell variable definition. :param line: A string to parse, must not start with '#' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline("aaa=") ('aaa', '') >>> _parseline("aaa=bbb") ('aaa', 'bbb') ...
[ "def", "_parseline", "(", "line", ")", ":", "match", "=", "re", ".", "match", "(", "r\"^\\s*(export)?\\s*(\\S+)=(?:(?:\"", "r\"(?:\\\"(.*[^\\\\])\\\")|(?:'(.*[^\\\\])')|\"", "r\"(?:([^\\\"'#\\s]+)))?)\\s*#*\"", ",", "line", ")", "if", "not", "match", ":", "LOGGER", ".",...
Parse a line contains shell variable definition. :param line: A string to parse, must not start with '#' (comment) :return: A tuple of (key, value), both key and value may be None >>> _parseline("aaa=") ('aaa', '') >>> _parseline("aaa=bbb") ('aaa', 'bbb') >>> _parseline("aaa='bb b'") (...
[ "Parse", "a", "line", "contains", "shell", "variable", "definition", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/shellvars.py#L35-L64
ssato/python-anyconfig
src/anyconfig/backend/shellvars.py
load
def load(stream, container=dict): """ Load and parse a file or file-like object 'stream' provides simple shell variables' definitions. :param stream: A file or file like object :param container: Factory function to create a dict-like object to store properties :return: Dict-like object ...
python
def load(stream, container=dict): """ Load and parse a file or file-like object 'stream' provides simple shell variables' definitions. :param stream: A file or file like object :param container: Factory function to create a dict-like object to store properties :return: Dict-like object ...
[ "def", "load", "(", "stream", ",", "container", "=", "dict", ")", ":", "ret", "=", "container", "(", ")", "for", "line", "in", "stream", ".", "readlines", "(", ")", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "line", "is", "None", "o...
Load and parse a file or file-like object 'stream' provides simple shell variables' definitions. :param stream: A file or file like object :param container: Factory function to create a dict-like object to store properties :return: Dict-like object holding shell variables' definitions >>> ...
[ "Load", "and", "parse", "a", "file", "or", "file", "-", "like", "object", "stream", "provides", "simple", "shell", "variables", "definitions", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/shellvars.py#L67-L103
ssato/python-anyconfig
src/anyconfig/backend/shellvars.py
Parser.dump_to_stream
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file or file-like object 'stream'. :param cnf: Shell variables data to dump :param stream: Shell script file or file like object :param kwargs: backend-specific optional keyword parameters :: dict ...
python
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file or file-like object 'stream'. :param cnf: Shell variables data to dump :param stream: Shell script file or file like object :param kwargs: backend-specific optional keyword parameters :: dict ...
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "val", "in", "anyconfig", ".", "compat", ".", "iteritems", "(", "cnf", ")", ":", "stream", ".", "write", "(", "\"%s='%s'%s\"", "%",...
Dump config 'cnf' to a file or file-like object 'stream'. :param cnf: Shell variables data to dump :param stream: Shell script file or file like object :param kwargs: backend-specific optional keyword parameters :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "or", "file", "-", "like", "object", "stream", "." ]
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/shellvars.py#L128-L137
jsvine/spectra
spectra/__init__.py
cmyk
def cmyk(c, m, y, k): """ Create a spectra.Color object in the CMYK color space. :param float c: c coordinate. :param float m: m coordinate. :param float y: y coordinate. :param float k: k coordinate. :rtype: Color :returns: A spectra.Color object in the CMYK color space. """ r...
python
def cmyk(c, m, y, k): """ Create a spectra.Color object in the CMYK color space. :param float c: c coordinate. :param float m: m coordinate. :param float y: y coordinate. :param float k: k coordinate. :rtype: Color :returns: A spectra.Color object in the CMYK color space. """ r...
[ "def", "cmyk", "(", "c", ",", "m", ",", "y", ",", "k", ")", ":", "return", "Color", "(", "\"cmyk\"", ",", "c", ",", "m", ",", "y", ",", "k", ")" ]
Create a spectra.Color object in the CMYK color space. :param float c: c coordinate. :param float m: m coordinate. :param float y: y coordinate. :param float k: k coordinate. :rtype: Color :returns: A spectra.Color object in the CMYK color space.
[ "Create", "a", "spectra", ".", "Color", "object", "in", "the", "CMYK", "color", "space", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/__init__.py#L63-L75
jsvine/spectra
spectra/grapefruit.py
Color.RgbToHsl
def RgbToHsl(r, g, b): '''Convert the color from RGB coordinates to HSL. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, l) tuple in the range: h...
python
def RgbToHsl(r, g, b): '''Convert the color from RGB coordinates to HSL. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, l) tuple in the range: h...
[ "def", "RgbToHsl", "(", "r", ",", "g", ",", "b", ")", ":", "minVal", "=", "min", "(", "r", ",", "g", ",", "b", ")", "# min RGB value", "maxVal", "=", "max", "(", "r", ",", "g", ",", "b", ")", "# max RGB value", "l", "=", "(", "maxVal", "+", "...
Convert the color from RGB coordinates to HSL. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, l) tuple in the range: h[0...360], s[0...1], ...
[ "Convert", "the", "color", "from", "RGB", "coordinates", "to", "HSL", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L365-L408
jsvine/spectra
spectra/grapefruit.py
Color.HslToRgb
def HslToRgb(h, s, l): '''Convert the color from HSL coordinates to RGB. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] Returns: The color as an (r, g, b) tuple in the rang...
python
def HslToRgb(h, s, l): '''Convert the color from HSL coordinates to RGB. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] Returns: The color as an (r, g, b) tuple in the rang...
[ "def", "HslToRgb", "(", "h", ",", "s", ",", "l", ")", ":", "if", "s", "==", "0", ":", "return", "(", "l", ",", "l", ",", "l", ")", "# achromatic (gray)", "if", "l", "<", "0.5", ":", "n2", "=", "l", "*", "(", "1.0", "+", "s", ")", "else", ...
Convert the color from HSL coordinates to RGB. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0.....
[ "Convert", "the", "color", "from", "HSL", "coordinates", "to", "RGB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L419-L453
jsvine/spectra
spectra/grapefruit.py
Color.RgbToHsv
def RgbToHsv(r, g, b): '''Convert the color from RGB coordinates to HSV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, v) tuple in the range: h...
python
def RgbToHsv(r, g, b): '''Convert the color from RGB coordinates to HSV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, v) tuple in the range: h...
[ "def", "RgbToHsv", "(", "r", ",", "g", ",", "b", ")", ":", "v", "=", "float", "(", "max", "(", "r", ",", "g", ",", "b", ")", ")", "d", "=", "v", "-", "min", "(", "r", ",", "g", ",", "b", ")", "if", "d", "==", "0", ":", "return", "(", ...
Convert the color from RGB coordinates to HSV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, v) tuple in the range: h[0...360], s[0...1], ...
[ "Convert", "the", "color", "from", "RGB", "coordinates", "to", "HSV", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L456-L492
jsvine/spectra
spectra/grapefruit.py
Color.HsvToRgb
def HsvToRgb(h, s, v): '''Convert the color from RGB coordinates to HSV. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] Returns: The color as an (r, g, b) tuple in the range: r...
python
def HsvToRgb(h, s, v): '''Convert the color from RGB coordinates to HSV. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] Returns: The color as an (r, g, b) tuple in the range: r...
[ "def", "HsvToRgb", "(", "h", ",", "s", ",", "v", ")", ":", "if", "s", "==", "0", ":", "return", "(", "v", ",", "v", ",", "v", ")", "# achromatic (gray)", "h", "/=", "60.0", "h", "=", "h", "%", "6.0", "i", "=", "int", "(", "h", ")", "f", "...
Convert the color from RGB coordinates to HSV. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], ...
[ "Convert", "the", "color", "from", "RGB", "coordinates", "to", "HSV", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L495-L533
jsvine/spectra
spectra/grapefruit.py
Color.RgbToYiq
def RgbToYiq(r, g, b): '''Convert the color from RGB to YIQ. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, i, q) tuple in the range: y[0...1], ...
python
def RgbToYiq(r, g, b): '''Convert the color from RGB to YIQ. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, i, q) tuple in the range: y[0...1], ...
[ "def", "RgbToYiq", "(", "r", ",", "g", ",", "b", ")", ":", "y", "=", "(", "r", "*", "0.29895808", ")", "+", "(", "g", "*", "0.58660979", ")", "+", "(", "b", "*", "0.11443213", ")", "i", "=", "(", "r", "*", "0.59590296", ")", "-", "(", "g", ...
Convert the color from RGB to YIQ. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, i, q) tuple in the range: y[0...1], i[0...1], q[0...1] ...
[ "Convert", "the", "color", "from", "RGB", "to", "YIQ", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L536-L560
jsvine/spectra
spectra/grapefruit.py
Color.YiqToRgb
def YiqToRgb(y, i, q): '''Convert the color from YIQ coordinates to RGB. Parameters: :y: Tte Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], ...
python
def YiqToRgb(y, i, q): '''Convert the color from YIQ coordinates to RGB. Parameters: :y: Tte Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], ...
[ "def", "YiqToRgb", "(", "y", ",", "i", ",", "q", ")", ":", "r", "=", "y", "+", "(", "i", "*", "0.9562", ")", "+", "(", "q", "*", "0.6210", ")", "g", "=", "y", "-", "(", "i", "*", "0.2717", ")", "-", "(", "q", "*", "0.6485", ")", "b", ...
Convert the color from YIQ coordinates to RGB. Parameters: :y: Tte Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1]...
[ "Convert", "the", "color", "from", "YIQ", "coordinates", "to", "RGB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L563-L587
jsvine/spectra
spectra/grapefruit.py
Color.RgbToYuv
def RgbToYuv(r, g, b): '''Convert the color from RGB coordinates to YUV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, u, v) tuple in the range: y...
python
def RgbToYuv(r, g, b): '''Convert the color from RGB coordinates to YUV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, u, v) tuple in the range: y...
[ "def", "RgbToYuv", "(", "r", ",", "g", ",", "b", ")", ":", "y", "=", "(", "r", "*", "0.29900", ")", "+", "(", "g", "*", "0.58700", ")", "+", "(", "b", "*", "0.11400", ")", "u", "=", "-", "(", "r", "*", "0.14713", ")", "-", "(", "g", "*"...
Convert the color from RGB coordinates to YUV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, u, v) tuple in the range: y[0...1], u[-0.436...0.43...
[ "Convert", "the", "color", "from", "RGB", "coordinates", "to", "YUV", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L590-L614
jsvine/spectra
spectra/grapefruit.py
Color.YuvToRgb
def YuvToRgb(y, u, v): '''Convert the color from YUV coordinates to RGB. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] Returns: The color as an (r, g, b) tuple in the range...
python
def YuvToRgb(y, u, v): '''Convert the color from YUV coordinates to RGB. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] Returns: The color as an (r, g, b) tuple in the range...
[ "def", "YuvToRgb", "(", "y", ",", "u", ",", "v", ")", ":", "r", "=", "y", "+", "(", "v", "*", "1.13983", ")", "g", "=", "y", "-", "(", "u", "*", "0.39465", ")", "-", "(", "v", "*", "0.58060", ")", "b", "=", "y", "+", "(", "u", "*", "2...
Convert the color from YUV coordinates to RGB. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0......
[ "Convert", "the", "color", "from", "YUV", "coordinates", "to", "RGB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L617-L641
jsvine/spectra
spectra/grapefruit.py
Color.RgbToXyz
def RgbToXyz(r, g, b): '''Convert the color from sRGB to CIE XYZ. The methods assumes that the RGB coordinates are given in the sRGB colorspace (D65). .. note:: Compensation for the sRGB gamma correction is applied before converting. Parameters: :r: The Red component value [...
python
def RgbToXyz(r, g, b): '''Convert the color from sRGB to CIE XYZ. The methods assumes that the RGB coordinates are given in the sRGB colorspace (D65). .. note:: Compensation for the sRGB gamma correction is applied before converting. Parameters: :r: The Red component value [...
[ "def", "RgbToXyz", "(", "r", ",", "g", ",", "b", ")", ":", "r", ",", "g", ",", "b", "=", "[", "(", "(", "v", "<=", "0.03928", ")", "and", "[", "v", "/", "12.92", "]", "or", "[", "(", "(", "v", "+", "0.055", ")", "/", "1.055", ")", "**",...
Convert the color from sRGB to CIE XYZ. The methods assumes that the RGB coordinates are given in the sRGB colorspace (D65). .. note:: Compensation for the sRGB gamma correction is applied before converting. Parameters: :r: The Red component value [0...1] :g: The G...
[ "Convert", "the", "color", "from", "sRGB", "to", "CIE", "XYZ", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L644-L677
jsvine/spectra
spectra/grapefruit.py
Color.XyzToRgb
def XyzToRgb(x, y, z): '''Convert the color from CIE XYZ coordinates to sRGB. .. note:: Compensation for sRGB gamma correction is applied before converting. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component...
python
def XyzToRgb(x, y, z): '''Convert the color from CIE XYZ coordinates to sRGB. .. note:: Compensation for sRGB gamma correction is applied before converting. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component...
[ "def", "XyzToRgb", "(", "x", ",", "y", ",", "z", ")", ":", "r", "=", "(", "x", "*", "3.2406255", ")", "-", "(", "y", "*", "1.5372080", ")", "-", "(", "z", "*", "0.4986286", ")", "g", "=", "-", "(", "x", "*", "0.9689307", ")", "+", "(", "y...
Convert the color from CIE XYZ coordinates to sRGB. .. note:: Compensation for sRGB gamma correction is applied before converting. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component value [0...1] Returns: ...
[ "Convert", "the", "color", "from", "CIE", "XYZ", "coordinates", "to", "sRGB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L680-L708
jsvine/spectra
spectra/grapefruit.py
Color.XyzToLab
def XyzToLab(x, y, z, wref=_DEFAULT_WREF): '''Convert the color from CIE XYZ to CIE L*a*b*. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component value [0...1] :wref: The whitepoint reference, default is 2° D6...
python
def XyzToLab(x, y, z, wref=_DEFAULT_WREF): '''Convert the color from CIE XYZ to CIE L*a*b*. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component value [0...1] :wref: The whitepoint reference, default is 2° D6...
[ "def", "XyzToLab", "(", "x", ",", "y", ",", "z", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "# White point correction", "x", "/=", "wref", "[", "0", "]", "y", "/=", "wref", "[", "1", "]", "z", "/=", "wref", "[", "2", "]", "# Nonlinear distortion an...
Convert the color from CIE XYZ to CIE L*a*b*. Parameters: :x: The X component value [0...1] :y: The Y component value [0...1] :z: The Z component value [0...1] :wref: The whitepoint reference, default is 2° D65. Returns: The color as an (L, a, b) t...
[ "Convert", "the", "color", "from", "CIE", "XYZ", "to", "CIE", "L", "*", "a", "*", "b", "*", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L711-L750
jsvine/spectra
spectra/grapefruit.py
Color.LabToXyz
def LabToXyz(l, a, b, wref=_DEFAULT_WREF): '''Convert the color from CIE L*a*b* to CIE 1931 XYZ. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :wref: The whitepoint reference, default is 2° D65. R...
python
def LabToXyz(l, a, b, wref=_DEFAULT_WREF): '''Convert the color from CIE L*a*b* to CIE 1931 XYZ. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :wref: The whitepoint reference, default is 2° D65. R...
[ "def", "LabToXyz", "(", "l", ",", "a", ",", "b", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "y", "=", "(", "l", "+", "16", ")", "/", "116", "x", "=", "(", "a", "/", "5.0", ")", "+", "y", "z", "=", "y", "-", "(", "b", "/", "2.0", ")", ...
Convert the color from CIE L*a*b* to CIE 1931 XYZ. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :wref: The whitepoint reference, default is 2° D65. Returns: The color as an (x, y, z) tuple in t...
[ "Convert", "the", "color", "from", "CIE", "L", "*", "a", "*", "b", "*", "to", "CIE", "1931", "XYZ", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L753-L782
jsvine/spectra
spectra/grapefruit.py
Color.CmykToCmy
def CmykToCmy(c, m, y, k): '''Convert the color from CMYK coordinates to CMY. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The Black component value [0...1] Return...
python
def CmykToCmy(c, m, y, k): '''Convert the color from CMYK coordinates to CMY. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The Black component value [0...1] Return...
[ "def", "CmykToCmy", "(", "c", ",", "m", ",", "y", ",", "k", ")", ":", "mk", "=", "1", "-", "k", "return", "(", "(", "c", "*", "mk", "+", "k", ")", ",", "(", "m", "*", "mk", "+", "k", ")", ",", "(", "y", "*", "mk", "+", "k", ")", ")"...
Convert the color from CMYK coordinates to CMY. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The Black component value [0...1] Returns: The color as an (c, m, y)...
[ "Convert", "the", "color", "from", "CMYK", "coordinates", "to", "CMY", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L785-L809
jsvine/spectra
spectra/grapefruit.py
Color.CmyToCmyk
def CmyToCmyk(c, m, y): '''Convert the color from CMY coordinates to CMYK. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] Returns: The color as an (c, m, y, k) tuple in the rang...
python
def CmyToCmyk(c, m, y): '''Convert the color from CMY coordinates to CMYK. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] Returns: The color as an (c, m, y, k) tuple in the rang...
[ "def", "CmyToCmyk", "(", "c", ",", "m", ",", "y", ")", ":", "k", "=", "min", "(", "c", ",", "m", ",", "y", ")", "if", "k", "==", "1.0", ":", "return", "(", "0.0", ",", "0.0", ",", "0.0", ",", "1.0", ")", "mk", "=", "1", "-", "k", "retur...
Convert the color from CMY coordinates to CMYK. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] Returns: The color as an (c, m, y, k) tuple in the range: c[0...1], m[0......
[ "Convert", "the", "color", "from", "CMY", "coordinates", "to", "CMYK", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L812-L837
jsvine/spectra
spectra/grapefruit.py
Color.RgbToIntTuple
def RgbToIntTuple(r, g, b): '''Convert the color from (r, g, b) to an int tuple. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the range:...
python
def RgbToIntTuple(r, g, b): '''Convert the color from (r, g, b) to an int tuple. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the range:...
[ "def", "RgbToIntTuple", "(", "r", ",", "g", ",", "b", ")", ":", "return", "tuple", "(", "int", "(", "round", "(", "v", "*", "255", ")", ")", "for", "v", "in", "(", "r", ",", "g", ",", "b", ")", ")" ]
Convert the color from (r, g, b) to an int tuple. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...255], g[0...2551...
[ "Convert", "the", "color", "from", "(", "r", "g", "b", ")", "to", "an", "int", "tuple", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L888-L909
jsvine/spectra
spectra/grapefruit.py
Color.RgbToHtml
def RgbToHtml(r, g, b): '''Convert the color from (r, g, b) to #RRGGBB. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A CSS string representation of this color (#RRGGBB). ...
python
def RgbToHtml(r, g, b): '''Convert the color from (r, g, b) to #RRGGBB. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A CSS string representation of this color (#RRGGBB). ...
[ "def", "RgbToHtml", "(", "r", ",", "g", ",", "b", ")", ":", "return", "'#%02x%02x%02x'", "%", "tuple", "(", "(", "min", "(", "round", "(", "v", "*", "255", ")", ",", "255", ")", "for", "v", "in", "(", "r", ",", "g", ",", "b", ")", ")", ")" ...
Convert the color from (r, g, b) to #RRGGBB. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A CSS string representation of this color (#RRGGBB). >>> Color.RgbToHtml(1, 0.5,...
[ "Convert", "the", "color", "from", "(", "r", "g", "b", ")", "to", "#RRGGBB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L934-L952
jsvine/spectra
spectra/grapefruit.py
Color.HtmlToRgb
def HtmlToRgb(html): '''Convert the HTML color to (r, g, b). Parameters: :html: the HTML definition of the color (#RRGGBB or #RGB or a color name). Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] Throws: :ValueError: ...
python
def HtmlToRgb(html): '''Convert the HTML color to (r, g, b). Parameters: :html: the HTML definition of the color (#RRGGBB or #RGB or a color name). Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] Throws: :ValueError: ...
[ "def", "HtmlToRgb", "(", "html", ")", ":", "html", "=", "html", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "html", "[", "0", "]", "==", "'#'", ":", "html", "=", "html", "[", "1", ":", "]", "elif", "html", "in", "Color", ".", "NAMED...
Convert the HTML color to (r, g, b). Parameters: :html: the HTML definition of the color (#RRGGBB or #RGB or a color name). Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] Throws: :ValueError: If html is neither a kno...
[ "Convert", "the", "HTML", "color", "to", "(", "r", "g", "b", ")", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L955-L998
jsvine/spectra
spectra/grapefruit.py
Color.RgbToPil
def RgbToPil(r, g, b): '''Convert the color from RGB to a PIL-compatible integer. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A PIL compatible integer (0xBBGGRR). >>...
python
def RgbToPil(r, g, b): '''Convert the color from RGB to a PIL-compatible integer. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A PIL compatible integer (0xBBGGRR). >>...
[ "def", "RgbToPil", "(", "r", ",", "g", ",", "b", ")", ":", "r", ",", "g", ",", "b", "=", "[", "min", "(", "int", "(", "round", "(", "v", "*", "255", ")", ")", ",", "255", ")", "for", "v", "in", "(", "r", ",", "g", ",", "b", ")", "]", ...
Convert the color from RGB to a PIL-compatible integer. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: A PIL compatible integer (0xBBGGRR). >>> '0x%06x' % Color.RgbToPil(1,...
[ "Convert", "the", "color", "from", "RGB", "to", "a", "PIL", "-", "compatible", "integer", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1001-L1020
jsvine/spectra
spectra/grapefruit.py
Color.PilToRgb
def PilToRgb(pil): '''Convert the color from a PIL-compatible integer to RGB. Parameters: pil: a PIL compatible color representation (0xBBGGRR) Returns: The color as an (r, g, b) tuple in the range: the range: r: [0...1] g: [0...1] b: [0...1] >>> '(%g, %g, %g)' % Co...
python
def PilToRgb(pil): '''Convert the color from a PIL-compatible integer to RGB. Parameters: pil: a PIL compatible color representation (0xBBGGRR) Returns: The color as an (r, g, b) tuple in the range: the range: r: [0...1] g: [0...1] b: [0...1] >>> '(%g, %g, %g)' % Co...
[ "def", "PilToRgb", "(", "pil", ")", ":", "r", "=", "0xff", "&", "pil", "g", "=", "0xff", "&", "(", "pil", ">>", "8", ")", "b", "=", "0xff", "&", "(", "pil", ">>", "16", ")", "return", "tuple", "(", "(", "v", "/", "255.0", "for", "v", "in", ...
Convert the color from a PIL-compatible integer to RGB. Parameters: pil: a PIL compatible color representation (0xBBGGRR) Returns: The color as an (r, g, b) tuple in the range: the range: r: [0...1] g: [0...1] b: [0...1] >>> '(%g, %g, %g)' % Color.PilToRgb(0x0080ff) ...
[ "Convert", "the", "color", "from", "a", "PIL", "-", "compatible", "integer", "to", "RGB", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1023-L1042
jsvine/spectra
spectra/grapefruit.py
Color._WebSafeComponent
def _WebSafeComponent(c, alt=False): '''Convert a color component to its web safe equivalent. Parameters: :c: The component value [0...1] :alt: If True, return the alternative value instead of the nearest one. Returns: The web safe equivalent of the component value. ...
python
def _WebSafeComponent(c, alt=False): '''Convert a color component to its web safe equivalent. Parameters: :c: The component value [0...1] :alt: If True, return the alternative value instead of the nearest one. Returns: The web safe equivalent of the component value. ...
[ "def", "_WebSafeComponent", "(", "c", ",", "alt", "=", "False", ")", ":", "# This sucks, but floating point between 0 and 1 is quite fuzzy...", "# So we just change the scale a while to make the equality tests", "# work, otherwise it gets wrong at some decimal far to the right.", "sc", "...
Convert a color component to its web safe equivalent. Parameters: :c: The component value [0...1] :alt: If True, return the alternative value instead of the nearest one. Returns: The web safe equivalent of the component value.
[ "Convert", "a", "color", "component", "to", "its", "web", "safe", "equivalent", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1045-L1077
jsvine/spectra
spectra/grapefruit.py
Color.RgbToWebSafe
def RgbToWebSafe(r, g, b, alt=False): '''Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color inste...
python
def RgbToWebSafe(r, g, b, alt=False): '''Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color inste...
[ "def", "RgbToWebSafe", "(", "r", ",", "g", ",", "b", ",", "alt", "=", "False", ")", ":", "webSafeComponent", "=", "Color", ".", "_WebSafeComponent", "return", "tuple", "(", "(", "webSafeComponent", "(", "v", ",", "alt", ")", "for", "v", "in", "(", "r...
Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used fo...
[ "Convert", "the", "color", "from", "RGB", "to", "web", "safe", "RGB" ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1080-L1106
jsvine/spectra
spectra/grapefruit.py
Color.RgbToGreyscale
def RgbToGreyscale(r, g, b): '''Convert the color from RGB to its greyscale equivalent Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the ...
python
def RgbToGreyscale(r, g, b): '''Convert the color from RGB to its greyscale equivalent Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the ...
[ "def", "RgbToGreyscale", "(", "r", ",", "g", ",", "b", ")", ":", "v", "=", "(", "r", "+", "g", "+", "b", ")", "/", "3.0", "return", "(", "v", ",", "v", ",", "v", ")" ]
Convert the color from RGB to its greyscale equivalent Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (r, g, b) tuple in the range: the range: r[0......
[ "Convert", "the", "color", "from", "RGB", "to", "its", "greyscale", "equivalent" ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1109-L1132
jsvine/spectra
spectra/grapefruit.py
Color.RgbToRyb
def RgbToRyb(hue): '''Maps a hue on the RGB color wheel to Itten's RYB wheel. Parameters: :hue: The hue on the RGB color wheel [0...360] Returns: An approximation of the corresponding hue on Itten's RYB wheel. >>> Color.RgbToRyb(15) 26.0 ''' d = hue % 15 i = int(h...
python
def RgbToRyb(hue): '''Maps a hue on the RGB color wheel to Itten's RYB wheel. Parameters: :hue: The hue on the RGB color wheel [0...360] Returns: An approximation of the corresponding hue on Itten's RYB wheel. >>> Color.RgbToRyb(15) 26.0 ''' d = hue % 15 i = int(h...
[ "def", "RgbToRyb", "(", "hue", ")", ":", "d", "=", "hue", "%", "15", "i", "=", "int", "(", "hue", "/", "15", ")", "x0", "=", "_RybWheel", "[", "i", "]", "x1", "=", "_RybWheel", "[", "i", "+", "1", "]", "return", "x0", "+", "(", "x1", "-", ...
Maps a hue on the RGB color wheel to Itten's RYB wheel. Parameters: :hue: The hue on the RGB color wheel [0...360] Returns: An approximation of the corresponding hue on Itten's RYB wheel. >>> Color.RgbToRyb(15) 26.0
[ "Maps", "a", "hue", "on", "the", "RGB", "color", "wheel", "to", "Itten", "s", "RYB", "wheel", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1135-L1153
jsvine/spectra
spectra/grapefruit.py
Color.RybToRgb
def RybToRgb(hue): '''Maps a hue on Itten's RYB color wheel to the standard RGB wheel. Parameters: :hue: The hue on Itten's RYB color wheel [0...360] Returns: An approximation of the corresponding hue on the standard RGB wheel. >>> Color.RybToRgb(15) 8.0 ''' d = hue %...
python
def RybToRgb(hue): '''Maps a hue on Itten's RYB color wheel to the standard RGB wheel. Parameters: :hue: The hue on Itten's RYB color wheel [0...360] Returns: An approximation of the corresponding hue on the standard RGB wheel. >>> Color.RybToRgb(15) 8.0 ''' d = hue %...
[ "def", "RybToRgb", "(", "hue", ")", ":", "d", "=", "hue", "%", "15", "i", "=", "int", "(", "hue", "/", "15", ")", "x0", "=", "_RgbWheel", "[", "i", "]", "x1", "=", "_RgbWheel", "[", "i", "+", "1", "]", "return", "x0", "+", "(", "x1", "-", ...
Maps a hue on Itten's RYB color wheel to the standard RGB wheel. Parameters: :hue: The hue on Itten's RYB color wheel [0...360] Returns: An approximation of the corresponding hue on the standard RGB wheel. >>> Color.RybToRgb(15) 8.0
[ "Maps", "a", "hue", "on", "Itten", "s", "RYB", "color", "wheel", "to", "the", "standard", "RGB", "wheel", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1156-L1174
jsvine/spectra
spectra/grapefruit.py
Color.NewFromRgb
def NewFromRgb(r, g, b, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed RGB values. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alpha: The color...
python
def NewFromRgb(r, g, b, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed RGB values. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alpha: The color...
[ "def", "NewFromRgb", "(", "r", ",", "g", ",", "b", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "(", "r", ",", "g", ",", "b", ")", ",", "'rgb'", ",", "alpha", ",", "wref", ")" ]
Create a new instance based on the specifed RGB values. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref: T...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "RGB", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1177-L1201
jsvine/spectra
spectra/grapefruit.py
Color.NewFromHsl
def NewFromHsl(h, s, l, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HSL values. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] :alpha: ...
python
def NewFromHsl(h, s, l, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HSL values. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] :alpha: ...
[ "def", "NewFromHsl", "(", "h", ",", "s", ",", "l", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "(", "h", ",", "s", ",", "l", ")", ",", "'hsl'", ",", "alpha", ",", "wref", ")" ]
Create a new instance based on the specifed HSL values. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref:...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "HSL", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1204-L1228
jsvine/spectra
spectra/grapefruit.py
Color.NewFromHsv
def NewFromHsv(h, s, v, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HSV values. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] :alpha: The color...
python
def NewFromHsv(h, s, v, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HSV values. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] :alpha: The color...
[ "def", "NewFromHsv", "(", "h", ",", "s", ",", "v", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "h2", ",", "s", ",", "l", "=", "Color", ".", "RgbToHsl", "(", "*", "Color", ".", "HsvToRgb", "(", "h", ",", "s", ",", "v...
Create a new instance based on the specifed HSV values. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] :alpha: The color transparency [0...1], default is opaque :wref: T...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "HSV", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1231-L1256
jsvine/spectra
spectra/grapefruit.py
Color.NewFromYiq
def NewFromYiq(y, i, q, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed YIQ values. Parameters: :y: The Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] :alpha: The color transpar...
python
def NewFromYiq(y, i, q, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed YIQ values. Parameters: :y: The Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] :alpha: The color transpar...
[ "def", "NewFromYiq", "(", "y", ",", "i", ",", "q", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "YiqToRgb", "(", "y", ",", "i", ",", "q", ")", ",", "'rgb'", ",", "alpha", ",", "wre...
Create a new instance based on the specifed YIQ values. Parameters: :y: The Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref: The whitep...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "YIQ", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1259-L1283
jsvine/spectra
spectra/grapefruit.py
Color.NewFromYuv
def NewFromYuv(y, u, v, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed YUV values. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] :alpha: ...
python
def NewFromYuv(y, u, v, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed YUV values. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] :alpha: ...
[ "def", "NewFromYuv", "(", "y", ",", "u", ",", "v", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "YuvToRgb", "(", "y", ",", "u", ",", "v", ")", ",", "'rgb'", ",", "alpha", ",", "wre...
Create a new instance based on the specifed YUV values. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] :alpha: The color transparency [0...1], default is opaque :wref: ...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "YUV", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1286-L1310
jsvine/spectra
spectra/grapefruit.py
Color.NewFromXyz
def NewFromXyz(x, y, z, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CIE-XYZ values. Parameters: :x: The Red component value [0...1] :y: The Green component value [0...1] :z: The Blue component value [0...1] :alpha: The c...
python
def NewFromXyz(x, y, z, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CIE-XYZ values. Parameters: :x: The Red component value [0...1] :y: The Green component value [0...1] :z: The Blue component value [0...1] :alpha: The c...
[ "def", "NewFromXyz", "(", "x", ",", "y", ",", "z", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "XyzToRgb", "(", "x", ",", "y", ",", "z", ")", ",", "'rgb'", ",", "alpha", ",", "wre...
Create a new instance based on the specifed CIE-XYZ values. Parameters: :x: The Red component value [0...1] :y: The Green component value [0...1] :z: The Blue component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref: ...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "CIE", "-", "XYZ", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1313-L1337
jsvine/spectra
spectra/grapefruit.py
Color.NewFromLab
def NewFromLab(l, a, b, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CIE-LAB values. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :alpha: The color transparency [0......
python
def NewFromLab(l, a, b, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CIE-LAB values. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :alpha: The color transparency [0......
[ "def", "NewFromLab", "(", "l", ",", "a", ",", "b", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "XyzToRgb", "(", "*", "Color", ".", "LabToXyz", "(", "l", ",", "a", ",", "b", ",", "...
Create a new instance based on the specifed CIE-LAB values. Parameters: :l: The L component [0...100] :a: The a component [-1...1] :b: The a component [-1...1] :alpha: The color transparency [0...1], default is opaque :wref: The whitepoint refer...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "CIE", "-", "LAB", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1340-L1368
jsvine/spectra
spectra/grapefruit.py
Color.NewFromCmy
def NewFromCmy(c, m, y, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CMY values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :alpha: The ...
python
def NewFromCmy(c, m, y, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CMY values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :alpha: The ...
[ "def", "NewFromCmy", "(", "c", ",", "m", ",", "y", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "CmyToRgb", "(", "c", ",", "m", ",", "y", ")", ",", "'rgb'", ",", "alpha", ",", "wre...
Create a new instance based on the specifed CMY values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref: ...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "CMY", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1371-L1395
jsvine/spectra
spectra/grapefruit.py
Color.NewFromCmyk
def NewFromCmyk(c, m, y, k, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CMYK values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The...
python
def NewFromCmyk(c, m, y, k, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed CMYK values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The...
[ "def", "NewFromCmyk", "(", "c", ",", "m", ",", "y", ",", "k", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "CmyToRgb", "(", "*", "Color", ".", "CmykToCmy", "(", "c", ",", "m", ",", ...
Create a new instance based on the specifed CMYK values. Parameters: :c: The Cyan component value [0...1] :m: The Magenta component value [0...1] :y: The Yellow component value [0...1] :k: The Black component value [0...1] :alpha: The color tran...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "CMYK", "values", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1398-L1424
jsvine/spectra
spectra/grapefruit.py
Color.NewFromHtml
def NewFromHtml(html, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HTML color definition. Parameters: :html: The HTML definition of the color (#RRGGBB or #RGB or a color name). :alpha: The color transparency [0...1], default is opaque. :wref: ...
python
def NewFromHtml(html, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed HTML color definition. Parameters: :html: The HTML definition of the color (#RRGGBB or #RGB or a color name). :alpha: The color transparency [0...1], default is opaque. :wref: ...
[ "def", "NewFromHtml", "(", "html", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "HtmlToRgb", "(", "html", ")", ",", "'rgb'", ",", "alpha", ",", "wref", ")" ]
Create a new instance based on the specifed HTML color definition. Parameters: :html: The HTML definition of the color (#RRGGBB or #RGB or a color name). :alpha: The color transparency [0...1], default is opaque. :wref: The whitepoint reference, default is 2° D65. Ret...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "HTML", "color", "definition", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1427-L1455
jsvine/spectra
spectra/grapefruit.py
Color.NewFromPil
def NewFromPil(pil, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed PIL color. Parameters: :pil: A PIL compatible color representation (0xBBGGRR) :alpha: The color transparency [0...1], default is opaque :wref: The whitepoint reference, d...
python
def NewFromPil(pil, alpha=1.0, wref=_DEFAULT_WREF): '''Create a new instance based on the specifed PIL color. Parameters: :pil: A PIL compatible color representation (0xBBGGRR) :alpha: The color transparency [0...1], default is opaque :wref: The whitepoint reference, d...
[ "def", "NewFromPil", "(", "pil", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "Color", ".", "PilToRgb", "(", "pil", ")", ",", "'rgb'", ",", "alpha", ",", "wref", ")" ]
Create a new instance based on the specifed PIL color. Parameters: :pil: A PIL compatible color representation (0xBBGGRR) :alpha: The color transparency [0...1], default is opaque :wref: The whitepoint reference, default is 2° D65. Returns: A grapefruit.Color in...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "PIL", "color", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1458-L1478
jsvine/spectra
spectra/grapefruit.py
Color.ColorWithWhiteRef
def ColorWithWhiteRef(self, wref, labAsRef=False): '''Create a new instance based on this one with a new white reference. Parameters: :wref: The whitepoint reference. :labAsRef: If True, the L*a*b* values of the current instance are used as reference for the new color; other...
python
def ColorWithWhiteRef(self, wref, labAsRef=False): '''Create a new instance based on this one with a new white reference. Parameters: :wref: The whitepoint reference. :labAsRef: If True, the L*a*b* values of the current instance are used as reference for the new color; other...
[ "def", "ColorWithWhiteRef", "(", "self", ",", "wref", ",", "labAsRef", "=", "False", ")", ":", "if", "labAsRef", ":", "l", ",", "a", ",", "b", "=", "self", ".", "__GetLAB", "(", ")", "return", "Color", ".", "NewFromLab", "(", "l", ",", "a", ",", ...
Create a new instance based on this one with a new white reference. Parameters: :wref: The whitepoint reference. :labAsRef: If True, the L*a*b* values of the current instance are used as reference for the new color; otherwise, the RGB values are used as reference. Returns: ...
[ "Create", "a", "new", "instance", "based", "on", "this", "one", "with", "a", "new", "white", "reference", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1565-L1602
jsvine/spectra
spectra/grapefruit.py
Color.ColorWithHue
def ColorWithHue(self, hue): '''Create a new instance based on this one with a new hue. Parameters: :hue: The hue of the new color [0...360]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithHue(60) (1.0, 1.0, 0.0, 1.0) >>> Color.NewFromHsl(3...
python
def ColorWithHue(self, hue): '''Create a new instance based on this one with a new hue. Parameters: :hue: The hue of the new color [0...360]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithHue(60) (1.0, 1.0, 0.0, 1.0) >>> Color.NewFromHsl(3...
[ "def", "ColorWithHue", "(", "self", ",", "hue", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "return", "Color", "(", "(", "hue", ",", "s", ",", "l", ")", ",", "'hsl'", ",", "self", ".", "__a", ",", "self", ".", "__wref", ")" ...
Create a new instance based on this one with a new hue. Parameters: :hue: The hue of the new color [0...360]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithHue(60) (1.0, 1.0, 0.0, 1.0) >>> Color.NewFromHsl(30, 1, 0.5).ColorWithHue(60).hsl ...
[ "Create", "a", "new", "instance", "based", "on", "this", "one", "with", "a", "new", "hue", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1604-L1621
jsvine/spectra
spectra/grapefruit.py
Color.ColorWithSaturation
def ColorWithSaturation(self, saturation): '''Create a new instance based on this one with a new saturation value. .. note:: The saturation is defined for the HSL mode. Parameters: :saturation: The saturation of the new color [0...1]. Returns: A grapefruit.Color instance. ...
python
def ColorWithSaturation(self, saturation): '''Create a new instance based on this one with a new saturation value. .. note:: The saturation is defined for the HSL mode. Parameters: :saturation: The saturation of the new color [0...1]. Returns: A grapefruit.Color instance. ...
[ "def", "ColorWithSaturation", "(", "self", ",", "saturation", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "return", "Color", "(", "(", "h", ",", "saturation", ",", "l", ")", ",", "'hsl'", ",", "self", ".", "__a", ",", "self", "....
Create a new instance based on this one with a new saturation value. .. note:: The saturation is defined for the HSL mode. Parameters: :saturation: The saturation of the new color [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithSat...
[ "Create", "a", "new", "instance", "based", "on", "this", "one", "with", "a", "new", "saturation", "value", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1623-L1644
jsvine/spectra
spectra/grapefruit.py
Color.ColorWithLightness
def ColorWithLightness(self, lightness): '''Create a new instance based on this one with a new lightness value. Parameters: :lightness: The lightness of the new color [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithLightness(0.25) (0.5,...
python
def ColorWithLightness(self, lightness): '''Create a new instance based on this one with a new lightness value. Parameters: :lightness: The lightness of the new color [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithLightness(0.25) (0.5,...
[ "def", "ColorWithLightness", "(", "self", ",", "lightness", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "return", "Color", "(", "(", "h", ",", "s", ",", "lightness", ")", ",", "'hsl'", ",", "self", ".", "__a", ",", "self", ".", ...
Create a new instance based on this one with a new lightness value. Parameters: :lightness: The lightness of the new color [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ColorWithLightness(0.25) (0.5, 0.25, 0.0, 1.0) >>> Color.NewFromHsl(30, 1,...
[ "Create", "a", "new", "instance", "based", "on", "this", "one", "with", "a", "new", "lightness", "value", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1646-L1663
jsvine/spectra
spectra/grapefruit.py
Color.LighterColor
def LighterColor(self, level): '''Create a new instance based on this one but lighter. Parameters: :level: The amount by which the color should be lightened to produce the new one [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).LighterColor(...
python
def LighterColor(self, level): '''Create a new instance based on this one but lighter. Parameters: :level: The amount by which the color should be lightened to produce the new one [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).LighterColor(...
[ "def", "LighterColor", "(", "self", ",", "level", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "return", "Color", "(", "(", "h", ",", "s", ",", "min", "(", "l", "+", "level", ",", "1", ")", ")", ",", "'hsl'", ",", "self", "...
Create a new instance based on this one but lighter. Parameters: :level: The amount by which the color should be lightened to produce the new one [0...1]. Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).LighterColor(0.25) (1.0, 0.75, 0.5, 1.0) >>...
[ "Create", "a", "new", "instance", "based", "on", "this", "one", "but", "lighter", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1685-L1703
jsvine/spectra
spectra/grapefruit.py
Color.WebSafeDither
def WebSafeDither(self): '''Return the two websafe colors nearest to this one. Returns: A tuple of two grapefruit.Color instances which are the two web safe colors closest this one. >>> c = Color.NewFromRgb(1.0, 0.45, 0.0) >>> c1, c2 = c.WebSafeDither() >>> str(c1) '(1, 0.4, 0, 1)'...
python
def WebSafeDither(self): '''Return the two websafe colors nearest to this one. Returns: A tuple of two grapefruit.Color instances which are the two web safe colors closest this one. >>> c = Color.NewFromRgb(1.0, 0.45, 0.0) >>> c1, c2 = c.WebSafeDither() >>> str(c1) '(1, 0.4, 0, 1)'...
[ "def", "WebSafeDither", "(", "self", ")", ":", "return", "(", "Color", "(", "Color", ".", "RgbToWebSafe", "(", "*", "self", ".", "__rgb", ")", ",", "'rgb'", ",", "self", ".", "__a", ",", "self", ".", "__wref", ")", ",", "Color", "(", "Color", ".", ...
Return the two websafe colors nearest to this one. Returns: A tuple of two grapefruit.Color instances which are the two web safe colors closest this one. >>> c = Color.NewFromRgb(1.0, 0.45, 0.0) >>> c1, c2 = c.WebSafeDither() >>> str(c1) '(1, 0.4, 0, 1)' >>> str(c2) '(1, 0.6, 0...
[ "Return", "the", "two", "websafe", "colors", "nearest", "to", "this", "one", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1745-L1762
jsvine/spectra
spectra/grapefruit.py
Color.Gradient
def Gradient(self, target, steps=100): '''Create a list with the gradient colors between this and the other color. Parameters: :target: The grapefruit.Color at the other end of the gradient. :steps: The number of gradients steps to create. Returns: A list of grapefruit.C...
python
def Gradient(self, target, steps=100): '''Create a list with the gradient colors between this and the other color. Parameters: :target: The grapefruit.Color at the other end of the gradient. :steps: The number of gradients steps to create. Returns: A list of grapefruit.C...
[ "def", "Gradient", "(", "self", ",", "target", ",", "steps", "=", "100", ")", ":", "gradient", "=", "[", "]", "rgba1", "=", "self", ".", "__rgb", "+", "(", "self", ".", "__a", ",", ")", "rgba2", "=", "target", ".", "__rgb", "+", "(", "target", ...
Create a list with the gradient colors between this and the other color. Parameters: :target: The grapefruit.Color at the other end of the gradient. :steps: The number of gradients steps to create. Returns: A list of grapefruit.Color instances. >>> c1 = Color.NewFromRgb...
[ "Create", "a", "list", "with", "the", "gradient", "colors", "between", "this", "and", "the", "other", "color", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1764-L1797
jsvine/spectra
spectra/grapefruit.py
Color.ComplementaryColor
def ComplementaryColor(self, mode='ryb'): '''Create a new instance which is the complementary color of this one. Parameters: :mode: Select which color wheel to use for the generation (ryb/rgb). Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ComplementaryCo...
python
def ComplementaryColor(self, mode='ryb'): '''Create a new instance which is the complementary color of this one. Parameters: :mode: Select which color wheel to use for the generation (ryb/rgb). Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ComplementaryCo...
[ "def", "ComplementaryColor", "(", "self", ",", "mode", "=", "'ryb'", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "if", "mode", "==", "'ryb'", ":", "h", "=", "Color", ".", "RgbToRyb", "(", "h", ")", "h", "=", "(", "h", "+", "...
Create a new instance which is the complementary color of this one. Parameters: :mode: Select which color wheel to use for the generation (ryb/rgb). Returns: A grapefruit.Color instance. >>> Color.NewFromHsl(30, 1, 0.5).ComplementaryColor(mode='rgb') (0.0, 0.5, 1.0, 1.0) >>> ...
[ "Create", "a", "new", "instance", "which", "is", "the", "complementary", "color", "of", "this", "one", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1799-L1822
jsvine/spectra
spectra/grapefruit.py
Color.MonochromeScheme
def MonochromeScheme(self): '''Return 4 colors in the same hue with varying saturation/lightness. Returns: A tuple of 4 grapefruit.Color in the same hue as this one, with varying saturation/lightness. >>> c = Color.NewFromHsl(30, 0.5, 0.5) >>> ['(%g, %g, %g)' % clr.hsl for clr in c.Monochr...
python
def MonochromeScheme(self): '''Return 4 colors in the same hue with varying saturation/lightness. Returns: A tuple of 4 grapefruit.Color in the same hue as this one, with varying saturation/lightness. >>> c = Color.NewFromHsl(30, 0.5, 0.5) >>> ['(%g, %g, %g)' % clr.hsl for clr in c.Monochr...
[ "def", "MonochromeScheme", "(", "self", ")", ":", "def", "_wrap", "(", "x", ",", "min", ",", "thres", ",", "plus", ")", ":", "if", "(", "x", "-", "min", ")", "<", "thres", ":", "return", "x", "+", "plus", "else", ":", "return", "x", "-", "min",...
Return 4 colors in the same hue with varying saturation/lightness. Returns: A tuple of 4 grapefruit.Color in the same hue as this one, with varying saturation/lightness. >>> c = Color.NewFromHsl(30, 0.5, 0.5) >>> ['(%g, %g, %g)' % clr.hsl for clr in c.MonochromeScheme()] ['(30, 0.2, 0.8)',...
[ "Return", "4", "colors", "in", "the", "same", "hue", "with", "varying", "saturation", "/", "lightness", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1824-L1858
jsvine/spectra
spectra/grapefruit.py
Color.TriadicScheme
def TriadicScheme(self, angle=120, mode='ryb'): '''Return two colors forming a triad or a split complementary with this one. Parameters: :angle: The angle between the hues of the created colors. The default value makes a triad. :mode: Select which color wheel to use for the ...
python
def TriadicScheme(self, angle=120, mode='ryb'): '''Return two colors forming a triad or a split complementary with this one. Parameters: :angle: The angle between the hues of the created colors. The default value makes a triad. :mode: Select which color wheel to use for the ...
[ "def", "TriadicScheme", "(", "self", ",", "angle", "=", "120", ",", "mode", "=", "'ryb'", ")", ":", "h", ",", "s", ",", "l", "=", "self", ".", "__hsl", "angle", "=", "min", "(", "angle", ",", "120", ")", "/", "2.0", "if", "mode", "==", "'ryb'",...
Return two colors forming a triad or a split complementary with this one. Parameters: :angle: The angle between the hues of the created colors. The default value makes a triad. :mode: Select which color wheel to use for the generation (ryb/rgb). Returns: A tuple of tw...
[ "Return", "two", "colors", "forming", "a", "triad", "or", "a", "split", "complementary", "with", "this", "one", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1860-L1902
jsvine/spectra
spectra/core.py
Color.from_html
def from_html(cls, html_string): """ Create sRGB color from a web-color name or hexcode. :param str html_string: Web-color name or hexcode. :rtype: Color :returns: A spectra.Color in the sRGB color space. """ rgb = GC.NewFromHtml(html_string).rgb return ...
python
def from_html(cls, html_string): """ Create sRGB color from a web-color name or hexcode. :param str html_string: Web-color name or hexcode. :rtype: Color :returns: A spectra.Color in the sRGB color space. """ rgb = GC.NewFromHtml(html_string).rgb return ...
[ "def", "from_html", "(", "cls", ",", "html_string", ")", ":", "rgb", "=", "GC", ".", "NewFromHtml", "(", "html_string", ")", ".", "rgb", "return", "cls", "(", "\"rgb\"", ",", "*", "rgb", ")" ]
Create sRGB color from a web-color name or hexcode. :param str html_string: Web-color name or hexcode. :rtype: Color :returns: A spectra.Color in the sRGB color space.
[ "Create", "sRGB", "color", "from", "a", "web", "-", "color", "name", "or", "hexcode", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L33-L43
jsvine/spectra
spectra/core.py
Color.to
def to(self, space): """ Convert color to a different color space. :param str space: Name of the color space. :rtype: Color :returns: A new spectra.Color in the given color space. """ if space == self.space: return self new_color = convert_color(self.col...
python
def to(self, space): """ Convert color to a different color space. :param str space: Name of the color space. :rtype: Color :returns: A new spectra.Color in the given color space. """ if space == self.space: return self new_color = convert_color(self.col...
[ "def", "to", "(", "self", ",", "space", ")", ":", "if", "space", "==", "self", ".", "space", ":", "return", "self", "new_color", "=", "convert_color", "(", "self", ".", "color_object", ",", "COLOR_SPACES", "[", "space", "]", ")", "return", "self", ".",...
Convert color to a different color space. :param str space: Name of the color space. :rtype: Color :returns: A new spectra.Color in the given color space.
[ "Convert", "color", "to", "a", "different", "color", "space", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L45-L56
jsvine/spectra
spectra/core.py
Color.blend
def blend(self, other, ratio=0.5): """ Blend this color with another color in the same color space. By default, blends the colors half-and-half (ratio: 0.5). :param Color other: The color to blend. :param float ratio: How much to blend (0 -> 1). :rtype: Color :...
python
def blend(self, other, ratio=0.5): """ Blend this color with another color in the same color space. By default, blends the colors half-and-half (ratio: 0.5). :param Color other: The color to blend. :param float ratio: How much to blend (0 -> 1). :rtype: Color :...
[ "def", "blend", "(", "self", ",", "other", ",", "ratio", "=", "0.5", ")", ":", "keep", "=", "1.0", "-", "ratio", "if", "not", "self", ".", "space", "==", "other", ".", "space", ":", "raise", "Exception", "(", "\"Colors must belong to the same color space.\...
Blend this color with another color in the same color space. By default, blends the colors half-and-half (ratio: 0.5). :param Color other: The color to blend. :param float ratio: How much to blend (0 -> 1). :rtype: Color :returns: A new spectra.Color
[ "Blend", "this", "color", "with", "another", "color", "in", "the", "same", "color", "space", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L68-L85
jsvine/spectra
spectra/core.py
Color.brighten
def brighten(self, amount=10): """ Brighten this color by `amount` luminance. Converts this color to the LCH color space, and then increases the `L` parameter by `amount`. :param float amount: Amount to increase the luminance. :rtype: Color :returns: A new spec...
python
def brighten(self, amount=10): """ Brighten this color by `amount` luminance. Converts this color to the LCH color space, and then increases the `L` parameter by `amount`. :param float amount: Amount to increase the luminance. :rtype: Color :returns: A new spec...
[ "def", "brighten", "(", "self", ",", "amount", "=", "10", ")", ":", "lch", "=", "self", ".", "to", "(", "\"lch\"", ")", "l", ",", "c", ",", "h", "=", "lch", ".", "values", "new_lch", "=", "self", ".", "__class__", "(", "\"lch\"", ",", "l", "+",...
Brighten this color by `amount` luminance. Converts this color to the LCH color space, and then increases the `L` parameter by `amount`. :param float amount: Amount to increase the luminance. :rtype: Color :returns: A new spectra.Color
[ "Brighten", "this", "color", "by", "amount", "luminance", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L87-L102
jsvine/spectra
spectra/core.py
Scale.colorspace
def colorspace(self, space): """ Create a new scale in the given color space. :param str space: The new color space. :rtype: Scale :returns: A new color.Scale object. """ new_colors = [ c.to(space) for c in self.colors ] return self.__class__(new_colors,...
python
def colorspace(self, space): """ Create a new scale in the given color space. :param str space: The new color space. :rtype: Scale :returns: A new color.Scale object. """ new_colors = [ c.to(space) for c in self.colors ] return self.__class__(new_colors,...
[ "def", "colorspace", "(", "self", ",", "space", ")", ":", "new_colors", "=", "[", "c", ".", "to", "(", "space", ")", "for", "c", "in", "self", ".", "colors", "]", "return", "self", ".", "__class__", "(", "new_colors", ",", "self", ".", "_domain", "...
Create a new scale in the given color space. :param str space: The new color space. :rtype: Scale :returns: A new color.Scale object.
[ "Create", "a", "new", "scale", "in", "the", "given", "color", "space", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L211-L221
jsvine/spectra
spectra/core.py
Scale.range
def range(self, count): """ Create a list of colors evenly spaced along this scale's domain. :param int count: The number of colors to return. :rtype: list :returns: A list of spectra.Color objects. """ if count <= 1: raise ValueError("Range size mus...
python
def range(self, count): """ Create a list of colors evenly spaced along this scale's domain. :param int count: The number of colors to return. :rtype: list :returns: A list of spectra.Color objects. """ if count <= 1: raise ValueError("Range size mus...
[ "def", "range", "(", "self", ",", "count", ")", ":", "if", "count", "<=", "1", ":", "raise", "ValueError", "(", "\"Range size must be greater than 1.\"", ")", "dom", "=", "self", ".", "_domain", "distance", "=", "dom", "[", "-", "1", "]", "-", "dom", "...
Create a list of colors evenly spaced along this scale's domain. :param int count: The number of colors to return. :rtype: list :returns: A list of spectra.Color objects.
[ "Create", "a", "list", "of", "colors", "evenly", "spaced", "along", "this", "scale", "s", "domain", "." ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L223-L238