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 |
|---|---|---|---|---|---|---|---|---|---|---|
gtaylor/python-colormath | colormath/chromatic_adaptation.py | _get_adaptation_matrix | def _get_adaptation_matrix(wp_src, wp_dst, observer, adaptation):
"""
Calculate the correct transformation matrix based on origin and target
illuminants. The observer angle must be the same between illuminants.
See colormath.color_constants.ADAPTATION_MATRICES for a list of possible
adaptations.
... | python | def _get_adaptation_matrix(wp_src, wp_dst, observer, adaptation):
"""
Calculate the correct transformation matrix based on origin and target
illuminants. The observer angle must be the same between illuminants.
See colormath.color_constants.ADAPTATION_MATRICES for a list of possible
adaptations.
... | [
"def",
"_get_adaptation_matrix",
"(",
"wp_src",
",",
"wp_dst",
",",
"observer",
",",
"adaptation",
")",
":",
"# Get the appropriate transformation matrix, [MsubA].",
"m_sharp",
"=",
"color_constants",
".",
"ADAPTATION_MATRICES",
"[",
"adaptation",
"]",
"# In case the white-... | Calculate the correct transformation matrix based on origin and target
illuminants. The observer angle must be the same between illuminants.
See colormath.color_constants.ADAPTATION_MATRICES for a list of possible
adaptations.
Detailed conversion documentation is available at:
http://brucelindbloo... | [
"Calculate",
"the",
"correct",
"transformation",
"matrix",
"based",
"on",
"origin",
"and",
"target",
"illuminants",
".",
"The",
"observer",
"angle",
"must",
"be",
"the",
"same",
"between",
"illuminants",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/chromatic_adaptation.py#L13-L51 |
gtaylor/python-colormath | colormath/chromatic_adaptation.py | apply_chromatic_adaptation | def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum,
observer='2', adaptation='bradford'):
"""
Applies a chromatic adaptation matrix to convert XYZ values between
illuminants. It is important to recognize that color transformation results
in color er... | python | def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum,
observer='2', adaptation='bradford'):
"""
Applies a chromatic adaptation matrix to convert XYZ values between
illuminants. It is important to recognize that color transformation results
in color er... | [
"def",
"apply_chromatic_adaptation",
"(",
"val_x",
",",
"val_y",
",",
"val_z",
",",
"orig_illum",
",",
"targ_illum",
",",
"observer",
"=",
"'2'",
",",
"adaptation",
"=",
"'bradford'",
")",
":",
"# It's silly to have to do this, but some people may want to call this",
"#... | Applies a chromatic adaptation matrix to convert XYZ values between
illuminants. It is important to recognize that color transformation results
in color errors, determined by how far the original illuminant is from the
target illuminant. For example, D65 to A could result in very high maximum
deviance.
... | [
"Applies",
"a",
"chromatic",
"adaptation",
"matrix",
"to",
"convert",
"XYZ",
"values",
"between",
"illuminants",
".",
"It",
"is",
"important",
"to",
"recognize",
"that",
"color",
"transformation",
"results",
"in",
"color",
"errors",
"determined",
"by",
"how",
"f... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/chromatic_adaptation.py#L55-L97 |
gtaylor/python-colormath | colormath/chromatic_adaptation.py | apply_chromatic_adaptation_on_color | def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation='bradford'):
"""
Convenience function to apply an adaptation directly to a Color object.
"""
xyz_x = color.xyz_x
xyz_y = color.xyz_y
xyz_z = color.xyz_z
orig_illum = color.illuminant
targ_illum = targ_illum.lower()
... | python | def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation='bradford'):
"""
Convenience function to apply an adaptation directly to a Color object.
"""
xyz_x = color.xyz_x
xyz_y = color.xyz_y
xyz_z = color.xyz_z
orig_illum = color.illuminant
targ_illum = targ_illum.lower()
... | [
"def",
"apply_chromatic_adaptation_on_color",
"(",
"color",
",",
"targ_illum",
",",
"adaptation",
"=",
"'bradford'",
")",
":",
"xyz_x",
"=",
"color",
".",
"xyz_x",
"xyz_y",
"=",
"color",
".",
"xyz_y",
"xyz_z",
"=",
"color",
".",
"xyz_z",
"orig_illum",
"=",
"... | Convenience function to apply an adaptation directly to a Color object. | [
"Convenience",
"function",
"to",
"apply",
"an",
"adaptation",
"directly",
"to",
"a",
"Color",
"object",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/chromatic_adaptation.py#L101-L119 |
gtaylor/python-colormath | examples/conversions.py | example_lab_to_xyz | def example_lab_to_xyz():
"""
This function shows a simple conversion of an Lab color to an XYZ color.
"""
print("=== Simple Example: Lab->XYZ ===")
# Instantiate an Lab color object with the given values.
lab = LabColor(0.903, 16.296, -2.22)
# Show a string representation.
print(lab)
... | python | def example_lab_to_xyz():
"""
This function shows a simple conversion of an Lab color to an XYZ color.
"""
print("=== Simple Example: Lab->XYZ ===")
# Instantiate an Lab color object with the given values.
lab = LabColor(0.903, 16.296, -2.22)
# Show a string representation.
print(lab)
... | [
"def",
"example_lab_to_xyz",
"(",
")",
":",
"print",
"(",
"\"=== Simple Example: Lab->XYZ ===\"",
")",
"# Instantiate an Lab color object with the given values.",
"lab",
"=",
"LabColor",
"(",
"0.903",
",",
"16.296",
",",
"-",
"2.22",
")",
"# Show a string representation.",
... | This function shows a simple conversion of an Lab color to an XYZ color. | [
"This",
"function",
"shows",
"a",
"simple",
"conversion",
"of",
"an",
"Lab",
"color",
"to",
"an",
"XYZ",
"color",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L17-L30 |
gtaylor/python-colormath | examples/conversions.py | example_lchab_to_lchuv | def example_lchab_to_lchuv():
"""
This function shows very complex chain of conversions in action.
LCHab to LCHuv involves four different calculations, making this the
conversion requiring the most steps.
"""
print("=== Complex Example: LCHab->LCHuv ===")
# Instantiate an LCHab color objec... | python | def example_lchab_to_lchuv():
"""
This function shows very complex chain of conversions in action.
LCHab to LCHuv involves four different calculations, making this the
conversion requiring the most steps.
"""
print("=== Complex Example: LCHab->LCHuv ===")
# Instantiate an LCHab color objec... | [
"def",
"example_lchab_to_lchuv",
"(",
")",
":",
"print",
"(",
"\"=== Complex Example: LCHab->LCHuv ===\"",
")",
"# Instantiate an LCHab color object with the given values.",
"lchab",
"=",
"LCHabColor",
"(",
"0.903",
",",
"16.447",
",",
"352.252",
")",
"# Show a string represe... | This function shows very complex chain of conversions in action.
LCHab to LCHuv involves four different calculations, making this the
conversion requiring the most steps. | [
"This",
"function",
"shows",
"very",
"complex",
"chain",
"of",
"conversions",
"in",
"action",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L33-L49 |
gtaylor/python-colormath | examples/conversions.py | example_lab_to_rgb | def example_lab_to_rgb():
"""
Conversions to RGB are a little more complex mathematically. There are also
several kinds of RGB color spaces. When converting from a device-independent
color space to RGB, sRGB is assumed unless otherwise specified with the
target_rgb keyword arg.
"""
print("=... | python | def example_lab_to_rgb():
"""
Conversions to RGB are a little more complex mathematically. There are also
several kinds of RGB color spaces. When converting from a device-independent
color space to RGB, sRGB is assumed unless otherwise specified with the
target_rgb keyword arg.
"""
print("=... | [
"def",
"example_lab_to_rgb",
"(",
")",
":",
"print",
"(",
"\"=== RGB Example: Lab->RGB ===\"",
")",
"# Instantiate an Lab color object with the given values.",
"lab",
"=",
"LabColor",
"(",
"0.903",
",",
"16.296",
",",
"-",
"2.217",
")",
"# Show a string representation.",
... | Conversions to RGB are a little more complex mathematically. There are also
several kinds of RGB color spaces. When converting from a device-independent
color space to RGB, sRGB is assumed unless otherwise specified with the
target_rgb keyword arg. | [
"Conversions",
"to",
"RGB",
"are",
"a",
"little",
"more",
"complex",
"mathematically",
".",
"There",
"are",
"also",
"several",
"kinds",
"of",
"RGB",
"color",
"spaces",
".",
"When",
"converting",
"from",
"a",
"device",
"-",
"independent",
"color",
"space",
"t... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L52-L68 |
gtaylor/python-colormath | examples/conversions.py | example_rgb_to_xyz | def example_rgb_to_xyz():
"""
The reverse is similar.
"""
print("=== RGB Example: RGB->XYZ ===")
# Instantiate an Lab color object with the given values.
rgb = sRGBColor(120, 130, 140)
# Show a string representation.
print(rgb)
# Convert RGB to XYZ using a D50 illuminant.
xyz = ... | python | def example_rgb_to_xyz():
"""
The reverse is similar.
"""
print("=== RGB Example: RGB->XYZ ===")
# Instantiate an Lab color object with the given values.
rgb = sRGBColor(120, 130, 140)
# Show a string representation.
print(rgb)
# Convert RGB to XYZ using a D50 illuminant.
xyz = ... | [
"def",
"example_rgb_to_xyz",
"(",
")",
":",
"print",
"(",
"\"=== RGB Example: RGB->XYZ ===\"",
")",
"# Instantiate an Lab color object with the given values.",
"rgb",
"=",
"sRGBColor",
"(",
"120",
",",
"130",
",",
"140",
")",
"# Show a string representation.",
"print",
"(... | The reverse is similar. | [
"The",
"reverse",
"is",
"similar",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L71-L84 |
gtaylor/python-colormath | examples/conversions.py | example_spectral_to_xyz | def example_spectral_to_xyz():
"""
Instantiate an Lab color object with the given values. Note that the
spectral range can run from 340nm to 830nm. Any omitted values assume a
value of 0.0, which is more or less ignored. For the distribution below,
we are providing an example reading from an X-Rite ... | python | def example_spectral_to_xyz():
"""
Instantiate an Lab color object with the given values. Note that the
spectral range can run from 340nm to 830nm. Any omitted values assume a
value of 0.0, which is more or less ignored. For the distribution below,
we are providing an example reading from an X-Rite ... | [
"def",
"example_spectral_to_xyz",
"(",
")",
":",
"print",
"(",
"\"=== Example: Spectral->XYZ ===\"",
")",
"spc",
"=",
"SpectralColor",
"(",
"observer",
"=",
"'2'",
",",
"illuminant",
"=",
"'d50'",
",",
"spec_380nm",
"=",
"0.0600",
",",
"spec_390nm",
"=",
"0.0600... | Instantiate an Lab color object with the given values. Note that the
spectral range can run from 340nm to 830nm. Any omitted values assume a
value of 0.0, which is more or less ignored. For the distribution below,
we are providing an example reading from an X-Rite i1 Pro, which only
measures between 380... | [
"Instantiate",
"an",
"Lab",
"color",
"object",
"with",
"the",
"given",
"values",
".",
"Note",
"that",
"the",
"spectral",
"range",
"can",
"run",
"from",
"340nm",
"to",
"830nm",
".",
"Any",
"omitted",
"values",
"assume",
"a",
"value",
"of",
"0",
".",
"0",
... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L87-L113 |
gtaylor/python-colormath | examples/conversions.py | example_lab_to_ipt | def example_lab_to_ipt():
"""
This function shows a simple conversion of an XYZ color to an IPT color.
"""
print("=== Simple Example: XYZ->IPT ===")
# Instantiate an XYZ color object with the given values.
xyz = XYZColor(0.5, 0.5, 0.5, illuminant='d65')
# Show a string representation.
p... | python | def example_lab_to_ipt():
"""
This function shows a simple conversion of an XYZ color to an IPT color.
"""
print("=== Simple Example: XYZ->IPT ===")
# Instantiate an XYZ color object with the given values.
xyz = XYZColor(0.5, 0.5, 0.5, illuminant='d65')
# Show a string representation.
p... | [
"def",
"example_lab_to_ipt",
"(",
")",
":",
"print",
"(",
"\"=== Simple Example: XYZ->IPT ===\"",
")",
"# Instantiate an XYZ color object with the given values.",
"xyz",
"=",
"XYZColor",
"(",
"0.5",
",",
"0.5",
",",
"0.5",
",",
"illuminant",
"=",
"'d65'",
")",
"# Show... | This function shows a simple conversion of an XYZ color to an IPT color. | [
"This",
"function",
"shows",
"a",
"simple",
"conversion",
"of",
"an",
"XYZ",
"color",
"to",
"an",
"IPT",
"color",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L116-L129 |
gtaylor/python-colormath | colormath/color_conversions.py | apply_RGB_matrix | def apply_RGB_matrix(var1, var2, var3, rgb_type, convtype="xyz_to_rgb"):
"""
Applies an RGB working matrix to convert from XYZ to RGB.
The arguments are tersely named var1, var2, and var3 to allow for the
passing of XYZ _or_ RGB values. var1 is X for XYZ, and R for RGB. var2 and
var3 follow suite.
... | python | def apply_RGB_matrix(var1, var2, var3, rgb_type, convtype="xyz_to_rgb"):
"""
Applies an RGB working matrix to convert from XYZ to RGB.
The arguments are tersely named var1, var2, and var3 to allow for the
passing of XYZ _or_ RGB values. var1 is X for XYZ, and R for RGB. var2 and
var3 follow suite.
... | [
"def",
"apply_RGB_matrix",
"(",
"var1",
",",
"var2",
",",
"var3",
",",
"rgb_type",
",",
"convtype",
"=",
"\"xyz_to_rgb\"",
")",
":",
"convtype",
"=",
"convtype",
".",
"lower",
"(",
")",
"# Retrieve the appropriate transformation matrix from the constants.",
"rgb_matri... | Applies an RGB working matrix to convert from XYZ to RGB.
The arguments are tersely named var1, var2, and var3 to allow for the
passing of XYZ _or_ RGB values. var1 is X for XYZ, and R for RGB. var2 and
var3 follow suite. | [
"Applies",
"an",
"RGB",
"working",
"matrix",
"to",
"convert",
"from",
"XYZ",
"to",
"RGB",
".",
"The",
"arguments",
"are",
"tersely",
"named",
"var1",
"var2",
"and",
"var3",
"to",
"allow",
"for",
"the",
"passing",
"of",
"XYZ",
"_or_",
"RGB",
"values",
"."... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L31-L55 |
gtaylor/python-colormath | colormath/color_conversions.py | color_conversion_function | def color_conversion_function(start_type, target_type):
"""
Decorator to indicate a function that performs a conversion from one color
space to another.
This decorator will return the original function unmodified, however it will
be registered in the _conversion_manager so it can be used to perform... | python | def color_conversion_function(start_type, target_type):
"""
Decorator to indicate a function that performs a conversion from one color
space to another.
This decorator will return the original function unmodified, however it will
be registered in the _conversion_manager so it can be used to perform... | [
"def",
"color_conversion_function",
"(",
"start_type",
",",
"target_type",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"f",
".",
"start_type",
"=",
"start_type",
"f",
".",
"target_type",
"=",
"target_type",
"_conversion_manager",
".",
"add_type_conversion",
... | Decorator to indicate a function that performs a conversion from one color
space to another.
This decorator will return the original function unmodified, however it will
be registered in the _conversion_manager so it can be used to perform color
space transformations between color spaces that do not ha... | [
"Decorator",
"to",
"indicate",
"a",
"function",
"that",
"performs",
"a",
"conversion",
"from",
"one",
"color",
"space",
"to",
"another",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L152-L173 |
gtaylor/python-colormath | colormath/color_conversions.py | Spectral_to_XYZ | def Spectral_to_XYZ(cobj, illuminant_override=None, *args, **kwargs):
"""
Converts spectral readings to XYZ.
"""
# If the user provides an illuminant_override numpy array, use it.
if illuminant_override:
reference_illum = illuminant_override
else:
# Otherwise, look up the illumin... | python | def Spectral_to_XYZ(cobj, illuminant_override=None, *args, **kwargs):
"""
Converts spectral readings to XYZ.
"""
# If the user provides an illuminant_override numpy array, use it.
if illuminant_override:
reference_illum = illuminant_override
else:
# Otherwise, look up the illumin... | [
"def",
"Spectral_to_XYZ",
"(",
"cobj",
",",
"illuminant_override",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the user provides an illuminant_override numpy array, use it.",
"if",
"illuminant_override",
":",
"reference_illum",
"=",
"illumina... | Converts spectral readings to XYZ. | [
"Converts",
"spectral",
"readings",
"to",
"XYZ",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L178-L226 |
gtaylor/python-colormath | colormath/color_conversions.py | Lab_to_LCHab | def Lab_to_LCHab(cobj, *args, **kwargs):
"""
Convert from CIE Lab to LCH(ab).
"""
lch_l = cobj.lab_l
lch_c = math.sqrt(
math.pow(float(cobj.lab_a), 2) + math.pow(float(cobj.lab_b), 2))
lch_h = math.atan2(float(cobj.lab_b), float(cobj.lab_a))
if lch_h > 0:
lch_h = (lch_h / ma... | python | def Lab_to_LCHab(cobj, *args, **kwargs):
"""
Convert from CIE Lab to LCH(ab).
"""
lch_l = cobj.lab_l
lch_c = math.sqrt(
math.pow(float(cobj.lab_a), 2) + math.pow(float(cobj.lab_b), 2))
lch_h = math.atan2(float(cobj.lab_b), float(cobj.lab_a))
if lch_h > 0:
lch_h = (lch_h / ma... | [
"def",
"Lab_to_LCHab",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lch_l",
"=",
"cobj",
".",
"lab_l",
"lch_c",
"=",
"math",
".",
"sqrt",
"(",
"math",
".",
"pow",
"(",
"float",
"(",
"cobj",
".",
"lab_a",
")",
",",
"2",
")"... | Convert from CIE Lab to LCH(ab). | [
"Convert",
"from",
"CIE",
"Lab",
"to",
"LCH",
"(",
"ab",
")",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L231-L246 |
gtaylor/python-colormath | colormath/color_conversions.py | Lab_to_XYZ | def Lab_to_XYZ(cobj, *args, **kwargs):
"""
Convert from Lab to XYZ
"""
illum = cobj.get_illuminant_xyz()
xyz_y = (cobj.lab_l + 16.0) / 116.0
xyz_x = cobj.lab_a / 500.0 + xyz_y
xyz_z = xyz_y - cobj.lab_b / 200.0
if math.pow(xyz_y, 3) > color_constants.CIE_E:
xyz_y = math.pow(xyz_... | python | def Lab_to_XYZ(cobj, *args, **kwargs):
"""
Convert from Lab to XYZ
"""
illum = cobj.get_illuminant_xyz()
xyz_y = (cobj.lab_l + 16.0) / 116.0
xyz_x = cobj.lab_a / 500.0 + xyz_y
xyz_z = xyz_y - cobj.lab_b / 200.0
if math.pow(xyz_y, 3) > color_constants.CIE_E:
xyz_y = math.pow(xyz_... | [
"def",
"Lab_to_XYZ",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"illum",
"=",
"cobj",
".",
"get_illuminant_xyz",
"(",
")",
"xyz_y",
"=",
"(",
"cobj",
".",
"lab_l",
"+",
"16.0",
")",
"/",
"116.0",
"xyz_x",
"=",
"cobj",
".",
... | Convert from Lab to XYZ | [
"Convert",
"from",
"Lab",
"to",
"XYZ"
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L251-L280 |
gtaylor/python-colormath | colormath/color_conversions.py | Luv_to_LCHuv | def Luv_to_LCHuv(cobj, *args, **kwargs):
"""
Convert from CIE Luv to LCH(uv).
"""
lch_l = cobj.luv_l
lch_c = math.sqrt(math.pow(cobj.luv_u, 2.0) + math.pow(cobj.luv_v, 2.0))
lch_h = math.atan2(float(cobj.luv_v), float(cobj.luv_u))
if lch_h > 0:
lch_h = (lch_h / math.pi) * 180
el... | python | def Luv_to_LCHuv(cobj, *args, **kwargs):
"""
Convert from CIE Luv to LCH(uv).
"""
lch_l = cobj.luv_l
lch_c = math.sqrt(math.pow(cobj.luv_u, 2.0) + math.pow(cobj.luv_v, 2.0))
lch_h = math.atan2(float(cobj.luv_v), float(cobj.luv_u))
if lch_h > 0:
lch_h = (lch_h / math.pi) * 180
el... | [
"def",
"Luv_to_LCHuv",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lch_l",
"=",
"cobj",
".",
"luv_l",
"lch_c",
"=",
"math",
".",
"sqrt",
"(",
"math",
".",
"pow",
"(",
"cobj",
".",
"luv_u",
",",
"2.0",
")",
"+",
"math",
".... | Convert from CIE Luv to LCH(uv). | [
"Convert",
"from",
"CIE",
"Luv",
"to",
"LCH",
"(",
"uv",
")",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L285-L298 |
gtaylor/python-colormath | colormath/color_conversions.py | Luv_to_XYZ | def Luv_to_XYZ(cobj, *args, **kwargs):
"""
Convert from Luv to XYZ.
"""
illum = cobj.get_illuminant_xyz()
# Without Light, there is no color. Short-circuit this and avoid some
# zero division errors in the var_a_frac calculation.
if cobj.luv_l <= 0.0:
xyz_x = 0.0
xyz_y = 0.0
... | python | def Luv_to_XYZ(cobj, *args, **kwargs):
"""
Convert from Luv to XYZ.
"""
illum = cobj.get_illuminant_xyz()
# Without Light, there is no color. Short-circuit this and avoid some
# zero division errors in the var_a_frac calculation.
if cobj.luv_l <= 0.0:
xyz_x = 0.0
xyz_y = 0.0
... | [
"def",
"Luv_to_XYZ",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"illum",
"=",
"cobj",
".",
"get_illuminant_xyz",
"(",
")",
"# Without Light, there is no color. Short-circuit this and avoid some",
"# zero division errors in the var_a_frac calculation."... | Convert from Luv to XYZ. | [
"Convert",
"from",
"Luv",
"to",
"XYZ",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L303-L337 |
gtaylor/python-colormath | colormath/color_conversions.py | LCHab_to_Lab | def LCHab_to_Lab(cobj, *args, **kwargs):
"""
Convert from LCH(ab) to Lab.
"""
lab_l = cobj.lch_l
lab_a = math.cos(math.radians(cobj.lch_h)) * cobj.lch_c
lab_b = math.sin(math.radians(cobj.lch_h)) * cobj.lch_c
return LabColor(
lab_l, lab_a, lab_b, illuminant=cobj.illuminant, observer=... | python | def LCHab_to_Lab(cobj, *args, **kwargs):
"""
Convert from LCH(ab) to Lab.
"""
lab_l = cobj.lch_l
lab_a = math.cos(math.radians(cobj.lch_h)) * cobj.lch_c
lab_b = math.sin(math.radians(cobj.lch_h)) * cobj.lch_c
return LabColor(
lab_l, lab_a, lab_b, illuminant=cobj.illuminant, observer=... | [
"def",
"LCHab_to_Lab",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lab_l",
"=",
"cobj",
".",
"lch_l",
"lab_a",
"=",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"cobj",
".",
"lch_h",
")",
")",
"*",
"cobj",
".",
"... | Convert from LCH(ab) to Lab. | [
"Convert",
"from",
"LCH",
"(",
"ab",
")",
"to",
"Lab",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L342-L350 |
gtaylor/python-colormath | colormath/color_conversions.py | LCHuv_to_Luv | def LCHuv_to_Luv(cobj, *args, **kwargs):
"""
Convert from LCH(uv) to Luv.
"""
luv_l = cobj.lch_l
luv_u = math.cos(math.radians(cobj.lch_h)) * cobj.lch_c
luv_v = math.sin(math.radians(cobj.lch_h)) * cobj.lch_c
return LuvColor(
luv_l, luv_u, luv_v, illuminant=cobj.illuminant, observer=... | python | def LCHuv_to_Luv(cobj, *args, **kwargs):
"""
Convert from LCH(uv) to Luv.
"""
luv_l = cobj.lch_l
luv_u = math.cos(math.radians(cobj.lch_h)) * cobj.lch_c
luv_v = math.sin(math.radians(cobj.lch_h)) * cobj.lch_c
return LuvColor(
luv_l, luv_u, luv_v, illuminant=cobj.illuminant, observer=... | [
"def",
"LCHuv_to_Luv",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"luv_l",
"=",
"cobj",
".",
"lch_l",
"luv_u",
"=",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"cobj",
".",
"lch_h",
")",
")",
"*",
"cobj",
".",
"... | Convert from LCH(uv) to Luv. | [
"Convert",
"from",
"LCH",
"(",
"uv",
")",
"to",
"Luv",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L355-L363 |
gtaylor/python-colormath | colormath/color_conversions.py | xyY_to_XYZ | def xyY_to_XYZ(cobj, *args, **kwargs):
"""
Convert from xyY to XYZ.
"""
# avoid division by zero
if cobj.xyy_y == 0.0:
xyz_x = 0.0
xyz_y = 0.0
xyz_z = 0.0
else:
xyz_x = (cobj.xyy_x * cobj.xyy_Y) / cobj.xyy_y
xyz_y = cobj.xyy_Y
xyz_z = ((1.0 - cobj.... | python | def xyY_to_XYZ(cobj, *args, **kwargs):
"""
Convert from xyY to XYZ.
"""
# avoid division by zero
if cobj.xyy_y == 0.0:
xyz_x = 0.0
xyz_y = 0.0
xyz_z = 0.0
else:
xyz_x = (cobj.xyy_x * cobj.xyy_Y) / cobj.xyy_y
xyz_y = cobj.xyy_Y
xyz_z = ((1.0 - cobj.... | [
"def",
"xyY_to_XYZ",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# avoid division by zero",
"if",
"cobj",
".",
"xyy_y",
"==",
"0.0",
":",
"xyz_x",
"=",
"0.0",
"xyz_y",
"=",
"0.0",
"xyz_z",
"=",
"0.0",
"else",
":",
"xyz_x",
"=",... | Convert from xyY to XYZ. | [
"Convert",
"from",
"xyY",
"to",
"XYZ",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L368-L383 |
gtaylor/python-colormath | colormath/color_conversions.py | XYZ_to_xyY | def XYZ_to_xyY(cobj, *args, **kwargs):
"""
Convert from XYZ to xyY.
"""
xyz_sum = cobj.xyz_x + cobj.xyz_y + cobj.xyz_z
# avoid division by zero
if xyz_sum == 0.0:
xyy_x = 0.0
xyy_y = 0.0
else:
xyy_x = cobj.xyz_x / xyz_sum
xyy_y = cobj.xyz_y / xyz_sum
xyy_Y... | python | def XYZ_to_xyY(cobj, *args, **kwargs):
"""
Convert from XYZ to xyY.
"""
xyz_sum = cobj.xyz_x + cobj.xyz_y + cobj.xyz_z
# avoid division by zero
if xyz_sum == 0.0:
xyy_x = 0.0
xyy_y = 0.0
else:
xyy_x = cobj.xyz_x / xyz_sum
xyy_y = cobj.xyz_y / xyz_sum
xyy_Y... | [
"def",
"XYZ_to_xyY",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"xyz_sum",
"=",
"cobj",
".",
"xyz_x",
"+",
"cobj",
".",
"xyz_y",
"+",
"cobj",
".",
"xyz_z",
"# avoid division by zero",
"if",
"xyz_sum",
"==",
"0.0",
":",
"xyy_x",
... | Convert from XYZ to xyY. | [
"Convert",
"from",
"XYZ",
"to",
"xyY",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L388-L403 |
gtaylor/python-colormath | colormath/color_conversions.py | XYZ_to_Luv | def XYZ_to_Luv(cobj, *args, **kwargs):
"""
Convert from XYZ to Luv
"""
temp_x = cobj.xyz_x
temp_y = cobj.xyz_y
temp_z = cobj.xyz_z
denom = temp_x + (15.0 * temp_y) + (3.0 * temp_z)
# avoid division by zero
if denom == 0.0:
luv_u = 0.0
luv_v = 0.0
else:
luv... | python | def XYZ_to_Luv(cobj, *args, **kwargs):
"""
Convert from XYZ to Luv
"""
temp_x = cobj.xyz_x
temp_y = cobj.xyz_y
temp_z = cobj.xyz_z
denom = temp_x + (15.0 * temp_y) + (3.0 * temp_z)
# avoid division by zero
if denom == 0.0:
luv_u = 0.0
luv_v = 0.0
else:
luv... | [
"def",
"XYZ_to_Luv",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"temp_x",
"=",
"cobj",
".",
"xyz_x",
"temp_y",
"=",
"cobj",
".",
"xyz_y",
"temp_z",
"=",
"cobj",
".",
"xyz_z",
"denom",
"=",
"temp_x",
"+",
"(",
"15.0",
"*",
"... | Convert from XYZ to Luv | [
"Convert",
"from",
"XYZ",
"to",
"Luv"
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L408-L439 |
gtaylor/python-colormath | colormath/color_conversions.py | XYZ_to_Lab | def XYZ_to_Lab(cobj, *args, **kwargs):
"""
Converts XYZ to Lab.
"""
illum = cobj.get_illuminant_xyz()
temp_x = cobj.xyz_x / illum["X"]
temp_y = cobj.xyz_y / illum["Y"]
temp_z = cobj.xyz_z / illum["Z"]
if temp_x > color_constants.CIE_E:
temp_x = math.pow(temp_x, (1.0 / 3.0))
... | python | def XYZ_to_Lab(cobj, *args, **kwargs):
"""
Converts XYZ to Lab.
"""
illum = cobj.get_illuminant_xyz()
temp_x = cobj.xyz_x / illum["X"]
temp_y = cobj.xyz_y / illum["Y"]
temp_z = cobj.xyz_z / illum["Z"]
if temp_x > color_constants.CIE_E:
temp_x = math.pow(temp_x, (1.0 / 3.0))
... | [
"def",
"XYZ_to_Lab",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"illum",
"=",
"cobj",
".",
"get_illuminant_xyz",
"(",
")",
"temp_x",
"=",
"cobj",
".",
"xyz_x",
"/",
"illum",
"[",
"\"X\"",
"]",
"temp_y",
"=",
"cobj",
".",
"xyz... | Converts XYZ to Lab. | [
"Converts",
"XYZ",
"to",
"Lab",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L444-L472 |
gtaylor/python-colormath | colormath/color_conversions.py | XYZ_to_RGB | def XYZ_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
XYZ to RGB conversion.
"""
temp_X = cobj.xyz_x
temp_Y = cobj.xyz_y
temp_Z = cobj.xyz_z
logger.debug(" \- Target RGB space: %s", target_rgb)
target_illum = target_rgb.native_illuminant
logger.debug(" \- Target native illuminant... | python | def XYZ_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
XYZ to RGB conversion.
"""
temp_X = cobj.xyz_x
temp_Y = cobj.xyz_y
temp_Z = cobj.xyz_z
logger.debug(" \- Target RGB space: %s", target_rgb)
target_illum = target_rgb.native_illuminant
logger.debug(" \- Target native illuminant... | [
"def",
"XYZ_to_RGB",
"(",
"cobj",
",",
"target_rgb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"temp_X",
"=",
"cobj",
".",
"xyz_x",
"temp_Y",
"=",
"cobj",
".",
"xyz_y",
"temp_Z",
"=",
"cobj",
".",
"xyz_z",
"logger",
".",
"debug",
"(",
"\... | XYZ to RGB conversion. | [
"XYZ",
"to",
"RGB",
"conversion",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L477-L537 |
gtaylor/python-colormath | colormath/color_conversions.py | RGB_to_XYZ | def RGB_to_XYZ(cobj, target_illuminant=None, *args, **kwargs):
"""
RGB to XYZ conversion. Expects 0-255 RGB values.
Based off of: http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html
"""
# Will contain linearized RGB channels (removed the gamma func).
linear_channels = {}
if isinst... | python | def RGB_to_XYZ(cobj, target_illuminant=None, *args, **kwargs):
"""
RGB to XYZ conversion. Expects 0-255 RGB values.
Based off of: http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html
"""
# Will contain linearized RGB channels (removed the gamma func).
linear_channels = {}
if isinst... | [
"def",
"RGB_to_XYZ",
"(",
"cobj",
",",
"target_illuminant",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Will contain linearized RGB channels (removed the gamma func).",
"linear_channels",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"cobj",
","... | RGB to XYZ conversion. Expects 0-255 RGB values.
Based off of: http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html | [
"RGB",
"to",
"XYZ",
"conversion",
".",
"Expects",
"0",
"-",
"255",
"RGB",
"values",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L542-L593 |
gtaylor/python-colormath | colormath/color_conversions.py | __RGB_to_Hue | def __RGB_to_Hue(var_R, var_G, var_B, var_min, var_max):
"""
For RGB_to_HSL and RGB_to_HSV, the Hue (H) component is calculated in
the same way.
"""
if var_max == var_min:
return 0.0
elif var_max == var_R:
return (60.0 * ((var_G - var_B) / (var_max - var_min)) + 360) % 360.0
... | python | def __RGB_to_Hue(var_R, var_G, var_B, var_min, var_max):
"""
For RGB_to_HSL and RGB_to_HSV, the Hue (H) component is calculated in
the same way.
"""
if var_max == var_min:
return 0.0
elif var_max == var_R:
return (60.0 * ((var_G - var_B) / (var_max - var_min)) + 360) % 360.0
... | [
"def",
"__RGB_to_Hue",
"(",
"var_R",
",",
"var_G",
",",
"var_B",
",",
"var_min",
",",
"var_max",
")",
":",
"if",
"var_max",
"==",
"var_min",
":",
"return",
"0.0",
"elif",
"var_max",
"==",
"var_R",
":",
"return",
"(",
"60.0",
"*",
"(",
"(",
"var_G",
"... | For RGB_to_HSL and RGB_to_HSV, the Hue (H) component is calculated in
the same way. | [
"For",
"RGB_to_HSL",
"and",
"RGB_to_HSV",
"the",
"Hue",
"(",
"H",
")",
"component",
"is",
"calculated",
"in",
"the",
"same",
"way",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L597-L609 |
gtaylor/python-colormath | colormath/color_conversions.py | RGB_to_HSV | def RGB_to_HSV(cobj, *args, **kwargs):
"""
Converts from RGB to HSV.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0.
"""
var_R = cobj.rgb_r
var_G = cobj.rgb_g
var_B = cobj.rgb_b
var_max = max(var_R, var_G, ... | python | def RGB_to_HSV(cobj, *args, **kwargs):
"""
Converts from RGB to HSV.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0.
"""
var_R = cobj.rgb_r
var_G = cobj.rgb_g
var_B = cobj.rgb_b
var_max = max(var_R, var_G, ... | [
"def",
"RGB_to_HSV",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"var_R",
"=",
"cobj",
".",
"rgb_r",
"var_G",
"=",
"cobj",
".",
"rgb_g",
"var_B",
"=",
"cobj",
".",
"rgb_b",
"var_max",
"=",
"max",
"(",
"var_R",
",",
"var_G",
... | Converts from RGB to HSV.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0. | [
"Converts",
"from",
"RGB",
"to",
"HSV",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L614-L639 |
gtaylor/python-colormath | colormath/color_conversions.py | RGB_to_HSL | def RGB_to_HSL(cobj, *args, **kwargs):
"""
Converts from RGB to HSL.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
L values are a percentage, 0.0 to 1.0.
"""
var_R = cobj.rgb_r
var_G = cobj.rgb_g
var_B = cobj.rgb_b
var_max = max(var_R, var_G, ... | python | def RGB_to_HSL(cobj, *args, **kwargs):
"""
Converts from RGB to HSL.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
L values are a percentage, 0.0 to 1.0.
"""
var_R = cobj.rgb_r
var_G = cobj.rgb_g
var_B = cobj.rgb_b
var_max = max(var_R, var_G, ... | [
"def",
"RGB_to_HSL",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"var_R",
"=",
"cobj",
".",
"rgb_r",
"var_G",
"=",
"cobj",
".",
"rgb_g",
"var_B",
"=",
"cobj",
".",
"rgb_b",
"var_max",
"=",
"max",
"(",
"var_R",
",",
"var_G",
... | Converts from RGB to HSL.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
L values are a percentage, 0.0 to 1.0. | [
"Converts",
"from",
"RGB",
"to",
"HSL",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L644-L670 |
gtaylor/python-colormath | colormath/color_conversions.py | __Calc_HSL_to_RGB_Components | def __Calc_HSL_to_RGB_Components(var_q, var_p, C):
"""
This is used in HSL_to_RGB conversions on R, G, and B.
"""
if C < 0:
C += 1.0
if C > 1:
C -= 1.0
# Computing C of vector (Color R, Color G, Color B)
if C < (1.0 / 6.0):
return var_p + ((var_q - var_p) * 6.0 * C)
... | python | def __Calc_HSL_to_RGB_Components(var_q, var_p, C):
"""
This is used in HSL_to_RGB conversions on R, G, and B.
"""
if C < 0:
C += 1.0
if C > 1:
C -= 1.0
# Computing C of vector (Color R, Color G, Color B)
if C < (1.0 / 6.0):
return var_p + ((var_q - var_p) * 6.0 * C)
... | [
"def",
"__Calc_HSL_to_RGB_Components",
"(",
"var_q",
",",
"var_p",
",",
"C",
")",
":",
"if",
"C",
"<",
"0",
":",
"C",
"+=",
"1.0",
"if",
"C",
">",
"1",
":",
"C",
"-=",
"1.0",
"# Computing C of vector (Color R, Color G, Color B)",
"if",
"C",
"<",
"(",
"1.... | This is used in HSL_to_RGB conversions on R, G, and B. | [
"This",
"is",
"used",
"in",
"HSL_to_RGB",
"conversions",
"on",
"R",
"G",
"and",
"B",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L674-L691 |
gtaylor/python-colormath | colormath/color_conversions.py | HSV_to_RGB | def HSV_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
HSV to RGB conversion.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0.
"""
H = cobj.hsv_h
S = cobj.hsv_s
V = cobj.hsv_v
h_floored = int(math.floor(H))
... | python | def HSV_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
HSV to RGB conversion.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0.
"""
H = cobj.hsv_h
S = cobj.hsv_s
V = cobj.hsv_v
h_floored = int(math.floor(H))
... | [
"def",
"HSV_to_RGB",
"(",
"cobj",
",",
"target_rgb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"H",
"=",
"cobj",
".",
"hsv_h",
"S",
"=",
"cobj",
".",
"hsv_s",
"V",
"=",
"cobj",
".",
"hsv_v",
"h_floored",
"=",
"int",
"(",
"math",
".",
... | HSV to RGB conversion.
H values are in degrees and are 0 to 360.
S values are a percentage, 0.0 to 1.0.
V values are a percentage, 0.0 to 1.0. | [
"HSV",
"to",
"RGB",
"conversion",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L696-L750 |
gtaylor/python-colormath | colormath/color_conversions.py | HSL_to_RGB | def HSL_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
HSL to RGB conversion.
"""
H = cobj.hsl_h
S = cobj.hsl_s
L = cobj.hsl_l
if L < 0.5:
var_q = L * (1.0 + S)
else:
var_q = L + S - (L * S)
var_p = 2.0 * L - var_q
# H normalized to range [0,1]
h_sub_k = (H... | python | def HSL_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
HSL to RGB conversion.
"""
H = cobj.hsl_h
S = cobj.hsl_s
L = cobj.hsl_l
if L < 0.5:
var_q = L * (1.0 + S)
else:
var_q = L + S - (L * S)
var_p = 2.0 * L - var_q
# H normalized to range [0,1]
h_sub_k = (H... | [
"def",
"HSL_to_RGB",
"(",
"cobj",
",",
"target_rgb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"H",
"=",
"cobj",
".",
"hsl_h",
"S",
"=",
"cobj",
".",
"hsl_s",
"L",
"=",
"cobj",
".",
"hsl_l",
"if",
"L",
"<",
"0.5",
":",
"var_q",
"=",
... | HSL to RGB conversion. | [
"HSL",
"to",
"RGB",
"conversion",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L755-L789 |
gtaylor/python-colormath | colormath/color_conversions.py | RGB_to_CMY | def RGB_to_CMY(cobj, *args, **kwargs):
"""
RGB to CMY conversion.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
cmy_c = 1.0 - cobj.rgb_r
cmy_m = 1.0 - cobj.rgb_g
cmy_y = 1.0 - cobj.rgb_b
return CMYColor(cmy_c, cmy_m, cmy_y) | python | def RGB_to_CMY(cobj, *args, **kwargs):
"""
RGB to CMY conversion.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
cmy_c = 1.0 - cobj.rgb_r
cmy_m = 1.0 - cobj.rgb_g
cmy_y = 1.0 - cobj.rgb_b
return CMYColor(cmy_c, cmy_m, cmy_y) | [
"def",
"RGB_to_CMY",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cmy_c",
"=",
"1.0",
"-",
"cobj",
".",
"rgb_r",
"cmy_m",
"=",
"1.0",
"-",
"cobj",
".",
"rgb_g",
"cmy_y",
"=",
"1.0",
"-",
"cobj",
".",
"rgb_b",
"return",
"CMYC... | RGB to CMY conversion.
NOTE: CMYK and CMY values range from 0.0 to 1.0 | [
"RGB",
"to",
"CMY",
"conversion",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L794-L804 |
gtaylor/python-colormath | colormath/color_conversions.py | CMY_to_RGB | def CMY_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
Converts CMY to RGB via simple subtraction.
NOTE: Returned values are in the range of 0-255.
"""
rgb_r = 1.0 - cobj.cmy_c
rgb_g = 1.0 - cobj.cmy_m
rgb_b = 1.0 - cobj.cmy_y
return target_rgb(rgb_r, rgb_g, rgb_b) | python | def CMY_to_RGB(cobj, target_rgb, *args, **kwargs):
"""
Converts CMY to RGB via simple subtraction.
NOTE: Returned values are in the range of 0-255.
"""
rgb_r = 1.0 - cobj.cmy_c
rgb_g = 1.0 - cobj.cmy_m
rgb_b = 1.0 - cobj.cmy_y
return target_rgb(rgb_r, rgb_g, rgb_b) | [
"def",
"CMY_to_RGB",
"(",
"cobj",
",",
"target_rgb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rgb_r",
"=",
"1.0",
"-",
"cobj",
".",
"cmy_c",
"rgb_g",
"=",
"1.0",
"-",
"cobj",
".",
"cmy_m",
"rgb_b",
"=",
"1.0",
"-",
"cobj",
".",
"cmy_... | Converts CMY to RGB via simple subtraction.
NOTE: Returned values are in the range of 0-255. | [
"Converts",
"CMY",
"to",
"RGB",
"via",
"simple",
"subtraction",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L809-L819 |
gtaylor/python-colormath | colormath/color_conversions.py | CMY_to_CMYK | def CMY_to_CMYK(cobj, *args, **kwargs):
"""
Converts from CMY to CMYK.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
var_k = 1.0
if cobj.cmy_c < var_k:
var_k = cobj.cmy_c
if cobj.cmy_m < var_k:
var_k = cobj.cmy_m
if cobj.cmy_y < var_k:
var_k = cobj.cmy_y
... | python | def CMY_to_CMYK(cobj, *args, **kwargs):
"""
Converts from CMY to CMYK.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
var_k = 1.0
if cobj.cmy_c < var_k:
var_k = cobj.cmy_c
if cobj.cmy_m < var_k:
var_k = cobj.cmy_m
if cobj.cmy_y < var_k:
var_k = cobj.cmy_y
... | [
"def",
"CMY_to_CMYK",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"var_k",
"=",
"1.0",
"if",
"cobj",
".",
"cmy_c",
"<",
"var_k",
":",
"var_k",
"=",
"cobj",
".",
"cmy_c",
"if",
"cobj",
".",
"cmy_m",
"<",
"var_k",
":",
"var_k"... | Converts from CMY to CMYK.
NOTE: CMYK and CMY values range from 0.0 to 1.0 | [
"Converts",
"from",
"CMY",
"to",
"CMYK",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L824-L848 |
gtaylor/python-colormath | colormath/color_conversions.py | CMYK_to_CMY | def CMYK_to_CMY(cobj, *args, **kwargs):
"""
Converts CMYK to CMY.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
cmy_c = cobj.cmyk_c * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
cmy_m = cobj.cmyk_m * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
cmy_y = cobj.cmyk_y * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
... | python | def CMYK_to_CMY(cobj, *args, **kwargs):
"""
Converts CMYK to CMY.
NOTE: CMYK and CMY values range from 0.0 to 1.0
"""
cmy_c = cobj.cmyk_c * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
cmy_m = cobj.cmyk_m * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
cmy_y = cobj.cmyk_y * (1.0 - cobj.cmyk_k) + cobj.cmyk_k
... | [
"def",
"CMYK_to_CMY",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cmy_c",
"=",
"cobj",
".",
"cmyk_c",
"*",
"(",
"1.0",
"-",
"cobj",
".",
"cmyk_k",
")",
"+",
"cobj",
".",
"cmyk_k",
"cmy_m",
"=",
"cobj",
".",
"cmyk_m",
"*",
... | Converts CMYK to CMY.
NOTE: CMYK and CMY values range from 0.0 to 1.0 | [
"Converts",
"CMYK",
"to",
"CMY",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L853-L863 |
gtaylor/python-colormath | colormath/color_conversions.py | XYZ_to_IPT | def XYZ_to_IPT(cobj, *args, **kwargs):
"""
Converts XYZ to IPT.
NOTE: XYZ values need to be adapted to 2 degree D65
Reference:
Fairchild, M. D. (2013). Color appearance models, 3rd Ed. (pp. 271-272). John Wiley & Sons.
"""
if cobj.illuminant != 'd65' or cobj.observer != '2':
raise ... | python | def XYZ_to_IPT(cobj, *args, **kwargs):
"""
Converts XYZ to IPT.
NOTE: XYZ values need to be adapted to 2 degree D65
Reference:
Fairchild, M. D. (2013). Color appearance models, 3rd Ed. (pp. 271-272). John Wiley & Sons.
"""
if cobj.illuminant != 'd65' or cobj.observer != '2':
raise ... | [
"def",
"XYZ_to_IPT",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cobj",
".",
"illuminant",
"!=",
"'d65'",
"or",
"cobj",
".",
"observer",
"!=",
"'2'",
":",
"raise",
"ValueError",
"(",
"'XYZColor for XYZ->IPT conversion needs to be... | Converts XYZ to IPT.
NOTE: XYZ values need to be adapted to 2 degree D65
Reference:
Fairchild, M. D. (2013). Color appearance models, 3rd Ed. (pp. 271-272). John Wiley & Sons. | [
"Converts",
"XYZ",
"to",
"IPT",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L868-L889 |
gtaylor/python-colormath | colormath/color_conversions.py | IPT_to_XYZ | def IPT_to_XYZ(cobj, *args, **kwargs):
"""
Converts IPT to XYZ.
"""
ipt_values = numpy.array(cobj.get_value_tuple())
lms_values = numpy.dot(
numpy.linalg.inv(IPTColor.conversion_matrices['lms_to_ipt']),
ipt_values)
lms_prime = numpy.sign(lms_values) * numpy.abs(lms_values) ** (1... | python | def IPT_to_XYZ(cobj, *args, **kwargs):
"""
Converts IPT to XYZ.
"""
ipt_values = numpy.array(cobj.get_value_tuple())
lms_values = numpy.dot(
numpy.linalg.inv(IPTColor.conversion_matrices['lms_to_ipt']),
ipt_values)
lms_prime = numpy.sign(lms_values) * numpy.abs(lms_values) ** (1... | [
"def",
"IPT_to_XYZ",
"(",
"cobj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ipt_values",
"=",
"numpy",
".",
"array",
"(",
"cobj",
".",
"get_value_tuple",
"(",
")",
")",
"lms_values",
"=",
"numpy",
".",
"dot",
"(",
"numpy",
".",
"linalg",
... | Converts IPT to XYZ. | [
"Converts",
"IPT",
"to",
"XYZ",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L894-L908 |
gtaylor/python-colormath | colormath/color_conversions.py | convert_color | def convert_color(color, target_cs, through_rgb_type=sRGBColor,
target_illuminant=None, *args, **kwargs):
"""
Converts the color to the designated color space.
:param color: A Color instance to convert.
:param target_cs: The Color class to convert to. Note that this is not
an ... | python | def convert_color(color, target_cs, through_rgb_type=sRGBColor,
target_illuminant=None, *args, **kwargs):
"""
Converts the color to the designated color space.
:param color: A Color instance to convert.
:param target_cs: The Color class to convert to. Note that this is not
an ... | [
"def",
"convert_color",
"(",
"color",
",",
"target_cs",
",",
"through_rgb_type",
"=",
"sRGBColor",
",",
"target_illuminant",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"target_cs",
",",
"str",
")",
":",
"ra... | Converts the color to the designated color space.
:param color: A Color instance to convert.
:param target_cs: The Color class to convert to. Note that this is not
an instance, but a class.
:keyword BaseRGBColor through_rgb_type: If during your conversion between
your original and target co... | [
"Converts",
"the",
"color",
"to",
"the",
"designated",
"color",
"space",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L929-L1015 |
gtaylor/python-colormath | colormath/color_conversions.py | ConversionManager.add_type_conversion | def add_type_conversion(self, start_type, target_type, conversion_function):
"""
Register a conversion function between two color spaces.
:param start_type: Starting color space.
:param target_type: Target color space.
:param conversion_function: Conversion function.
"""
... | python | def add_type_conversion(self, start_type, target_type, conversion_function):
"""
Register a conversion function between two color spaces.
:param start_type: Starting color space.
:param target_type: Target color space.
:param conversion_function: Conversion function.
"""
... | [
"def",
"add_type_conversion",
"(",
"self",
",",
"start_type",
",",
"target_type",
",",
"conversion_function",
")",
":",
"self",
".",
"registered_color_spaces",
".",
"add",
"(",
"start_type",
")",
"self",
".",
"registered_color_spaces",
".",
"add",
"(",
"target_typ... | Register a conversion function between two color spaces.
:param start_type: Starting color space.
:param target_type: Target color space.
:param conversion_function: Conversion function. | [
"Register",
"a",
"conversion",
"function",
"between",
"two",
"color",
"spaces",
".",
":",
"param",
"start_type",
":",
"Starting",
"color",
"space",
".",
":",
"param",
"target_type",
":",
"Target",
"color",
"space",
".",
":",
"param",
"conversion_function",
":"... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_conversions.py#L64-L74 |
gtaylor/python-colormath | colormath/color_appearance_models.py | Hunt._adaptation | def _adaptation(self, f_l, l_a, xyz, xyz_w, xyz_b, xyz_p=None, p=None, helson_judd=False, discount_illuminant=True):
"""
:param f_l: Luminance adaptation factor
:param l_a: Adapting luminance
:param xyz: Stimulus color in XYZ
:param xyz_w: Reference white color in XYZ
:pa... | python | def _adaptation(self, f_l, l_a, xyz, xyz_w, xyz_b, xyz_p=None, p=None, helson_judd=False, discount_illuminant=True):
"""
:param f_l: Luminance adaptation factor
:param l_a: Adapting luminance
:param xyz: Stimulus color in XYZ
:param xyz_w: Reference white color in XYZ
:pa... | [
"def",
"_adaptation",
"(",
"self",
",",
"f_l",
",",
"l_a",
",",
"xyz",
",",
"xyz_w",
",",
"xyz_b",
",",
"xyz_p",
"=",
"None",
",",
"p",
"=",
"None",
",",
"helson_judd",
"=",
"False",
",",
"discount_illuminant",
"=",
"True",
")",
":",
"rgb",
"=",
"s... | :param f_l: Luminance adaptation factor
:param l_a: Adapting luminance
:param xyz: Stimulus color in XYZ
:param xyz_w: Reference white color in XYZ
:param xyz_b: Background color in XYZ
:param xyz_p: Proxima field color in XYZ
:param p: Simultaneous contrast/assimilation ... | [
":",
"param",
"f_l",
":",
"Luminance",
"adaptation",
"factor",
":",
"param",
"l_a",
":",
"Adapting",
"luminance",
":",
"param",
"xyz",
":",
"Stimulus",
"color",
"in",
"XYZ",
":",
"param",
"xyz_w",
":",
"Reference",
"white",
"color",
"in",
"XYZ",
":",
"pa... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_appearance_models.py#L497-L545 |
gtaylor/python-colormath | colormath/color_appearance_models.py | Hunt.adjust_white_for_scc | def adjust_white_for_scc(cls, rgb_p, rgb_b, rgb_w, p):
"""
Adjust the white point for simultaneous chromatic contrast.
:param rgb_p: Cone signals of proxima field.
:param rgb_b: Cone signals of background.
:param rgb_w: Cone signals of reference white.
:param p: Simultan... | python | def adjust_white_for_scc(cls, rgb_p, rgb_b, rgb_w, p):
"""
Adjust the white point for simultaneous chromatic contrast.
:param rgb_p: Cone signals of proxima field.
:param rgb_b: Cone signals of background.
:param rgb_w: Cone signals of reference white.
:param p: Simultan... | [
"def",
"adjust_white_for_scc",
"(",
"cls",
",",
"rgb_p",
",",
"rgb_b",
",",
"rgb_w",
",",
"p",
")",
":",
"p_rgb",
"=",
"rgb_p",
"/",
"rgb_b",
"rgb_w",
"=",
"rgb_w",
"*",
"(",
"(",
"(",
"1",
"-",
"p",
")",
"*",
"p_rgb",
"+",
"(",
"1",
"+",
"p",
... | Adjust the white point for simultaneous chromatic contrast.
:param rgb_p: Cone signals of proxima field.
:param rgb_b: Cone signals of background.
:param rgb_w: Cone signals of reference white.
:param p: Simultaneous contrast/assimilation parameter.
:return: Adjusted cone signal... | [
"Adjust",
"the",
"white",
"point",
"for",
"simultaneous",
"chromatic",
"contrast",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_appearance_models.py#L548-L560 |
gtaylor/python-colormath | colormath/color_appearance_models.py | Hunt._get_cct | def _get_cct(x, y, z):
"""
Reference
Hernandez-Andres, J., Lee, R. L., & Romero, J. (1999).
Calculating correlated color temperatures across the entire gamut of daylight and skylight chromaticities.
Applied Optics, 38(27), 5703-5709.
"""
x_e = 0.3320
y_e =... | python | def _get_cct(x, y, z):
"""
Reference
Hernandez-Andres, J., Lee, R. L., & Romero, J. (1999).
Calculating correlated color temperatures across the entire gamut of daylight and skylight chromaticities.
Applied Optics, 38(27), 5703-5709.
"""
x_e = 0.3320
y_e =... | [
"def",
"_get_cct",
"(",
"x",
",",
"y",
",",
"z",
")",
":",
"x_e",
"=",
"0.3320",
"y_e",
"=",
"0.1858",
"n",
"=",
"(",
"(",
"x",
"/",
"(",
"x",
"+",
"z",
"+",
"z",
")",
")",
"-",
"x_e",
")",
"/",
"(",
"(",
"y",
"/",
"(",
"x",
"+",
"z",... | Reference
Hernandez-Andres, J., Lee, R. L., & Romero, J. (1999).
Calculating correlated color temperatures across the entire gamut of daylight and skylight chromaticities.
Applied Optics, 38(27), 5703-5709. | [
"Reference",
"Hernandez",
"-",
"Andres",
"J",
".",
"Lee",
"R",
".",
"L",
".",
"&",
"Romero",
"J",
".",
"(",
"1999",
")",
".",
"Calculating",
"correlated",
"color",
"temperatures",
"across",
"the",
"entire",
"gamut",
"of",
"daylight",
"and",
"skylight",
"... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_appearance_models.py#L563-L585 |
gtaylor/python-colormath | colormath/color_appearance_models.py | CIECAM02m1._compute_adaptation | def _compute_adaptation(self, xyz, xyz_w, f_l, d):
"""
Modified adaptation procedure incorporating simultaneous chromatic contrast from Hunt model.
:param xyz: Stimulus XYZ.
:param xyz_w: Reference white XYZ.
:param f_l: Luminance adaptation factor
:param d: Degree of ad... | python | def _compute_adaptation(self, xyz, xyz_w, f_l, d):
"""
Modified adaptation procedure incorporating simultaneous chromatic contrast from Hunt model.
:param xyz: Stimulus XYZ.
:param xyz_w: Reference white XYZ.
:param f_l: Luminance adaptation factor
:param d: Degree of ad... | [
"def",
"_compute_adaptation",
"(",
"self",
",",
"xyz",
",",
"xyz_w",
",",
"f_l",
",",
"d",
")",
":",
"# Transform input colors to cone responses",
"rgb",
"=",
"self",
".",
"_xyz_to_rgb",
"(",
"xyz",
")",
"logger",
".",
"debug",
"(",
"\"RGB: {}\"",
".",
"form... | Modified adaptation procedure incorporating simultaneous chromatic contrast from Hunt model.
:param xyz: Stimulus XYZ.
:param xyz_w: Reference white XYZ.
:param f_l: Luminance adaptation factor
:param d: Degree of adaptation.
:return: Tuple of adapted rgb and rgb_w arrays. | [
"Modified",
"adaptation",
"procedure",
"incorporating",
"simultaneous",
"chromatic",
"contrast",
"from",
"Hunt",
"model",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_appearance_models.py#L1245-L1280 |
twilio/authy-python | authy/api/resources.py | Instance.errors | def errors(self):
"""
:return error dict if no success:
"""
if self.ok():
return {}
errors = self.content
if(not isinstance(errors, dict)):
errors = {"error": errors} # convert to dict for consistency
elif('errors' in errors):
... | python | def errors(self):
"""
:return error dict if no success:
"""
if self.ok():
return {}
errors = self.content
if(not isinstance(errors, dict)):
errors = {"error": errors} # convert to dict for consistency
elif('errors' in errors):
... | [
"def",
"errors",
"(",
"self",
")",
":",
"if",
"self",
".",
"ok",
"(",
")",
":",
"return",
"{",
"}",
"errors",
"=",
"self",
".",
"content",
"if",
"(",
"not",
"isinstance",
"(",
"errors",
",",
"dict",
")",
")",
":",
"errors",
"=",
"{",
"\"error\"",... | :return error dict if no success: | [
":",
"return",
"error",
"dict",
"if",
"no",
"success",
":"
] | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L151-L165 |
twilio/authy-python | authy/api/resources.py | Users.create | def create(self, email, phone, country_code=1, send_install_link_via_sms=False):
"""
sends request to create new user.
:param string email:
:param string phone:
:param string country_code:
:param bool send_install_link_via_sms:
:return:
"""
data = ... | python | def create(self, email, phone, country_code=1, send_install_link_via_sms=False):
"""
sends request to create new user.
:param string email:
:param string phone:
:param string country_code:
:param bool send_install_link_via_sms:
:return:
"""
data = ... | [
"def",
"create",
"(",
"self",
",",
"email",
",",
"phone",
",",
"country_code",
"=",
"1",
",",
"send_install_link_via_sms",
"=",
"False",
")",
":",
"data",
"=",
"{",
"\"user\"",
":",
"{",
"\"email\"",
":",
"email",
",",
"\"cellphone\"",
":",
"phone",
",",... | sends request to create new user.
:param string email:
:param string phone:
:param string country_code:
:param bool send_install_link_via_sms:
:return: | [
"sends",
"request",
"to",
"create",
"new",
"user",
".",
":",
"param",
"string",
"email",
":",
":",
"param",
"string",
"phone",
":",
":",
"param",
"string",
"country_code",
":",
":",
"param",
"bool",
"send_install_link_via_sms",
":",
":",
"return",
":"
] | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L220-L241 |
twilio/authy-python | authy/api/resources.py | Phones.verification_start | def verification_start(self, phone_number, country_code, via='sms',
locale=None, code_length=4):
"""
:param string phone_number: stored in your databse or you provided while creating new user.
:param string country_code: stored in your databse or you provided while cre... | python | def verification_start(self, phone_number, country_code, via='sms',
locale=None, code_length=4):
"""
:param string phone_number: stored in your databse or you provided while creating new user.
:param string country_code: stored in your databse or you provided while cre... | [
"def",
"verification_start",
"(",
"self",
",",
"phone_number",
",",
"country_code",
",",
"via",
"=",
"'sms'",
",",
"locale",
"=",
"None",
",",
"code_length",
"=",
"4",
")",
":",
"if",
"via",
"!=",
"'sms'",
"and",
"via",
"!=",
"'call'",
":",
"raise",
"A... | :param string phone_number: stored in your databse or you provided while creating new user.
:param string country_code: stored in your databse or you provided while creating new user.
:param string via: verification method either sms or call
:param string locale: optional default none
:p... | [
":",
"param",
"string",
"phone_number",
":",
"stored",
"in",
"your",
"databse",
"or",
"you",
"provided",
"while",
"creating",
"new",
"user",
".",
":",
"param",
"string",
"country_code",
":",
"stored",
"in",
"your",
"databse",
"or",
"you",
"provided",
"while"... | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L327-L360 |
twilio/authy-python | authy/api/resources.py | Phones.verification_check | def verification_check(self, phone_number, country_code, verification_code):
"""
:param phone_number:
:param country_code:
:param verification_code:
:return:
"""
options = {
'phone_number': phone_number,
'country_code': country_code,
... | python | def verification_check(self, phone_number, country_code, verification_code):
"""
:param phone_number:
:param country_code:
:param verification_code:
:return:
"""
options = {
'phone_number': phone_number,
'country_code': country_code,
... | [
"def",
"verification_check",
"(",
"self",
",",
"phone_number",
",",
"country_code",
",",
"verification_code",
")",
":",
"options",
"=",
"{",
"'phone_number'",
":",
"phone_number",
",",
"'country_code'",
":",
"country_code",
",",
"'verification_code'",
":",
"verifica... | :param phone_number:
:param country_code:
:param verification_code:
:return: | [
":",
"param",
"phone_number",
":",
":",
"param",
"country_code",
":",
":",
"param",
"verification_code",
":",
":",
"return",
":"
] | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L362-L375 |
twilio/authy-python | authy/api/resources.py | OneTouch.send_request | def send_request(self, user_id, message, seconds_to_expire=None, details={}, hidden_details={}, logos=[]):
"""
OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string user_id: user_id User's authy id stored... | python | def send_request(self, user_id, message, seconds_to_expire=None, details={}, hidden_details={}, logos=[]):
"""
OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string user_id: user_id User's authy id stored... | [
"def",
"send_request",
"(",
"self",
",",
"user_id",
",",
"message",
",",
"seconds_to_expire",
"=",
"None",
",",
"details",
"=",
"{",
"}",
",",
"hidden_details",
"=",
"{",
"}",
",",
"logos",
"=",
"[",
"]",
")",
":",
"self",
".",
"_validate_request",
"("... | OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string user_id: user_id User's authy id stored in your database
:param string message: Required, the message shown to the user when the approval request arrives.
... | [
"OneTouch",
"verification",
"request",
".",
"Sends",
"a",
"request",
"for",
"Auth",
"App",
".",
"For",
"more",
"info",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"authy",
"/",
"authy",
"-",
"onetouch",
"-",
"a... | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L427-L452 |
twilio/authy-python | authy/api/resources.py | OneTouch.clean_logos | def clean_logos(self, logos):
"""
Validate logos input.
:param list logos:
:return list logos:
"""
if not len(logos):
return logos # Allow nil hash
if not isinstance(logos, list):
raise AuthyFormatException(
'Invalid logos ... | python | def clean_logos(self, logos):
"""
Validate logos input.
:param list logos:
:return list logos:
"""
if not len(logos):
return logos # Allow nil hash
if not isinstance(logos, list):
raise AuthyFormatException(
'Invalid logos ... | [
"def",
"clean_logos",
"(",
"self",
",",
"logos",
")",
":",
"if",
"not",
"len",
"(",
"logos",
")",
":",
"return",
"logos",
"# Allow nil hash",
"if",
"not",
"isinstance",
"(",
"logos",
",",
"list",
")",
":",
"raise",
"AuthyFormatException",
"(",
"'Invalid lo... | Validate logos input.
:param list logos:
:return list logos: | [
"Validate",
"logos",
"input",
".",
":",
"param",
"list",
"logos",
":",
":",
"return",
"list",
"logos",
":"
] | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L454-L488 |
twilio/authy-python | authy/api/resources.py | OneTouch.get_approval_status | def get_approval_status(self, uuid):
"""
OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string uuid Required. The approval request ID. (Obtained from the response to an ApprovalRequest):
:return O... | python | def get_approval_status(self, uuid):
"""
OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string uuid Required. The approval request ID. (Obtained from the response to an ApprovalRequest):
:return O... | [
"def",
"get_approval_status",
"(",
"self",
",",
"uuid",
")",
":",
"request_url",
"=",
"\"/onetouch/json/approval_requests/{0}\"",
".",
"format",
"(",
"uuid",
")",
"response",
"=",
"self",
".",
"get",
"(",
"request_url",
")",
"return",
"OneTouchResponse",
"(",
"s... | OneTouch verification request. Sends a request for Auth App. For more info https://www.twilio.com/docs/api/authy/authy-onetouch-api
:param string uuid Required. The approval request ID. (Obtained from the response to an ApprovalRequest):
:return OneTouchResponse the server response Json Object: | [
"OneTouch",
"verification",
"request",
".",
"Sends",
"a",
"request",
"for",
"Auth",
"App",
".",
"For",
"more",
"info",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"authy",
"/",
"authy",
"-",
"onetouch",
"-",
"a... | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L490-L498 |
twilio/authy-python | authy/api/resources.py | OneTouch.validate_one_touch_signature | def validate_one_touch_signature(self, signature, nonce, method, url, params):
"""
Function to validate signature in X-Authy-Signature key of headers.
:param string signature: X-Authy-Signature key of headers.
:param string nonce: X-Authy-Signature-Nonce key of headers.
:param s... | python | def validate_one_touch_signature(self, signature, nonce, method, url, params):
"""
Function to validate signature in X-Authy-Signature key of headers.
:param string signature: X-Authy-Signature key of headers.
:param string nonce: X-Authy-Signature-Nonce key of headers.
:param s... | [
"def",
"validate_one_touch_signature",
"(",
"self",
",",
"signature",
",",
"nonce",
",",
"method",
",",
"url",
",",
"params",
")",
":",
"if",
"not",
"signature",
"or",
"not",
"isinstance",
"(",
"signature",
",",
"str",
")",
":",
"raise",
"AuthyFormatExceptio... | Function to validate signature in X-Authy-Signature key of headers.
:param string signature: X-Authy-Signature key of headers.
:param string nonce: X-Authy-Signature-Nonce key of headers.
:param string method: GET or POST - configured in app settings for OneTouch.
:param string url: bas... | [
"Function",
"to",
"validate",
"signature",
"in",
"X",
"-",
"Authy",
"-",
"Signature",
"key",
"of",
"headers",
"."
] | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L500-L541 |
twilio/authy-python | authy/api/resources.py | OneTouch.__make_http_query | def __make_http_query(self, params, topkey=''):
"""
Function to covert params into url encoded query string
:param dict params: Json string sent by Authy.
:param string topkey: params key
:return string: url encoded Query.
"""
if len(params) == 0:
ret... | python | def __make_http_query(self, params, topkey=''):
"""
Function to covert params into url encoded query string
:param dict params: Json string sent by Authy.
:param string topkey: params key
:return string: url encoded Query.
"""
if len(params) == 0:
ret... | [
"def",
"__make_http_query",
"(",
"self",
",",
"params",
",",
"topkey",
"=",
"''",
")",
":",
"if",
"len",
"(",
"params",
")",
"==",
"0",
":",
"return",
"\"\"",
"result",
"=",
"\"\"",
"# is a dictionary?",
"if",
"type",
"(",
"params",
")",
"is",
"dict",
... | Function to covert params into url encoded query string
:param dict params: Json string sent by Authy.
:param string topkey: params key
:return string: url encoded Query. | [
"Function",
"to",
"covert",
"params",
"into",
"url",
"encoded",
"query",
"string",
":",
"param",
"dict",
"params",
":",
"Json",
"string",
"sent",
"by",
"Authy",
".",
":",
"param",
"string",
"topkey",
":",
"params",
"key",
":",
"return",
"string",
":",
"u... | train | https://github.com/twilio/authy-python/blob/7a0073b39a56bac495b10e4b4fca3f09982de6ed/authy/api/resources.py#L543-L582 |
doloopwhile/pyjq | pyjq.py | compile | def compile(script, vars={}, library_paths=[]):
"""
Compile a jq script, retuning a script object.
library_paths is a list of strings that defines the module search path.
"""
return _pyjq.Script(script.encode('utf-8'), vars=vars,
library_paths=library_paths) | python | def compile(script, vars={}, library_paths=[]):
"""
Compile a jq script, retuning a script object.
library_paths is a list of strings that defines the module search path.
"""
return _pyjq.Script(script.encode('utf-8'), vars=vars,
library_paths=library_paths) | [
"def",
"compile",
"(",
"script",
",",
"vars",
"=",
"{",
"}",
",",
"library_paths",
"=",
"[",
"]",
")",
":",
"return",
"_pyjq",
".",
"Script",
"(",
"script",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"vars",
"=",
"vars",
",",
"library_paths",
"=",
"l... | Compile a jq script, retuning a script object.
library_paths is a list of strings that defines the module search path. | [
"Compile",
"a",
"jq",
"script",
"retuning",
"a",
"script",
"object",
"."
] | train | https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L11-L19 |
doloopwhile/pyjq | pyjq.py | apply | def apply(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform value by script, returning all results as list.
"""
return all(script, value, vars, url, opener, library_paths) | python | def apply(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform value by script, returning all results as list.
"""
return all(script, value, vars, url, opener, library_paths) | [
"def",
"apply",
"(",
"script",
",",
"value",
"=",
"None",
",",
"vars",
"=",
"{",
"}",
",",
"url",
"=",
"None",
",",
"opener",
"=",
"default_opener",
",",
"library_paths",
"=",
"[",
"]",
")",
":",
"return",
"all",
"(",
"script",
",",
"value",
",",
... | Transform value by script, returning all results as list. | [
"Transform",
"value",
"by",
"script",
"returning",
"all",
"results",
"as",
"list",
"."
] | train | https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L52-L56 |
doloopwhile/pyjq | pyjq.py | first | def first(script, value=None, default=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform object by jq script, returning the first result.
Return default if result is empty.
"""
return compile(script, vars, library_paths).first(_get_value(value, url, opener), default) | python | def first(script, value=None, default=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform object by jq script, returning the first result.
Return default if result is empty.
"""
return compile(script, vars, library_paths).first(_get_value(value, url, opener), default) | [
"def",
"first",
"(",
"script",
",",
"value",
"=",
"None",
",",
"default",
"=",
"None",
",",
"vars",
"=",
"{",
"}",
",",
"url",
"=",
"None",
",",
"opener",
"=",
"default_opener",
",",
"library_paths",
"=",
"[",
"]",
")",
":",
"return",
"compile",
"(... | Transform object by jq script, returning the first result.
Return default if result is empty. | [
"Transform",
"object",
"by",
"jq",
"script",
"returning",
"the",
"first",
"result",
".",
"Return",
"default",
"if",
"result",
"is",
"empty",
"."
] | train | https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L61-L66 |
doloopwhile/pyjq | pyjq.py | one | def one(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform object by jq script, returning the first result.
Raise ValueError unless results does not include exactly one element.
"""
return compile(script, vars, library_paths).one(_get_value(value, url, ope... | python | def one(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]):
"""
Transform object by jq script, returning the first result.
Raise ValueError unless results does not include exactly one element.
"""
return compile(script, vars, library_paths).one(_get_value(value, url, ope... | [
"def",
"one",
"(",
"script",
",",
"value",
"=",
"None",
",",
"vars",
"=",
"{",
"}",
",",
"url",
"=",
"None",
",",
"opener",
"=",
"default_opener",
",",
"library_paths",
"=",
"[",
"]",
")",
":",
"return",
"compile",
"(",
"script",
",",
"vars",
",",
... | Transform object by jq script, returning the first result.
Raise ValueError unless results does not include exactly one element. | [
"Transform",
"object",
"by",
"jq",
"script",
"returning",
"the",
"first",
"result",
".",
"Raise",
"ValueError",
"unless",
"results",
"does",
"not",
"include",
"exactly",
"one",
"element",
"."
] | train | https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L69-L74 |
ambv/flake8-mypy | flake8_mypy.py | calculate_mypypath | def calculate_mypypath() -> List[str]:
"""Return MYPYPATH so that stubs have precedence over local sources."""
typeshed_root = None
count = 0
started = time.time()
for parent in itertools.chain(
# Look in current script's parents, useful for zipapps.
Path(__file__).parents,
... | python | def calculate_mypypath() -> List[str]:
"""Return MYPYPATH so that stubs have precedence over local sources."""
typeshed_root = None
count = 0
started = time.time()
for parent in itertools.chain(
# Look in current script's parents, useful for zipapps.
Path(__file__).parents,
... | [
"def",
"calculate_mypypath",
"(",
")",
"->",
"List",
"[",
"str",
"]",
":",
"typeshed_root",
"=",
"None",
"count",
"=",
"0",
"started",
"=",
"time",
".",
"time",
"(",
")",
"for",
"parent",
"in",
"itertools",
".",
"chain",
"(",
"# Look in current script's pa... | Return MYPYPATH so that stubs have precedence over local sources. | [
"Return",
"MYPYPATH",
"so",
"that",
"stubs",
"have",
"precedence",
"over",
"local",
"sources",
"."
] | train | https://github.com/ambv/flake8-mypy/blob/616eeb98092edfa0affc00c6cf4f7073f4de26a6/flake8_mypy.py#L52-L100 |
LPgenerator/django-db-mailer | dbmail/providers/pubnub/push.py | send | def send(channel, message, **kwargs):
"""
Site: http://www.pubnub.com/
API: https://www.mashape.com/pubnub/pubnub-network
Desc: real-time browser notifications
Installation and usage:
pip install -U pubnub
Tests for browser notification http://127.0.0.1:8000/browser_notification/
"""
... | python | def send(channel, message, **kwargs):
"""
Site: http://www.pubnub.com/
API: https://www.mashape.com/pubnub/pubnub-network
Desc: real-time browser notifications
Installation and usage:
pip install -U pubnub
Tests for browser notification http://127.0.0.1:8000/browser_notification/
"""
... | [
"def",
"send",
"(",
"channel",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"pubnub",
"=",
"Pubnub",
"(",
"publish_key",
"=",
"settings",
".",
"PUBNUB_PUB_KEY",
",",
"subscribe_key",
"=",
"settings",
".",
"PUBNUB_SUB_KEY",
",",
"secret_key",
"=",
"se... | Site: http://www.pubnub.com/
API: https://www.mashape.com/pubnub/pubnub-network
Desc: real-time browser notifications
Installation and usage:
pip install -U pubnub
Tests for browser notification http://127.0.0.1:8000/browser_notification/ | [
"Site",
":",
"http",
":",
"//",
"www",
".",
"pubnub",
".",
"com",
"/",
"API",
":",
"https",
":",
"//",
"www",
".",
"mashape",
".",
"com",
"/",
"pubnub",
"/",
"pubnub",
"-",
"network",
"Desc",
":",
"real",
"-",
"time",
"browser",
"notifications"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/pubnub/push.py#L11-L27 |
LPgenerator/django-db-mailer | dbmail/providers/boxcar/push.py | send | def send(token, title, **kwargs):
"""
Site: https://boxcar.io/
API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
Desc: Best app for system administrators
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),... | python | def send(token, title, **kwargs):
"""
Site: https://boxcar.io/
API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
Desc: Best app for system administrators
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),... | [
"def",
"send",
"(",
"token",
",",
"title",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"}",
"data",
... | Site: https://boxcar.io/
API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
Desc: Best app for system administrators | [
"Site",
":",
"https",
":",
"//",
"boxcar",
".",
"io",
"/",
"API",
":",
"http",
":",
"//",
"help",
".",
"boxcar",
".",
"io",
"/",
"knowledgebase",
"/",
"topics",
"/",
"48115",
"-",
"boxcar",
"-",
"api",
"Desc",
":",
"Best",
"app",
"for",
"system",
... | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/boxcar/push.py#L19-L48 |
LPgenerator/django-db-mailer | dbmail/providers/slack/push.py | send | def send(channel, message, **kwargs):
"""
Site: https://slack.com
API: https://api.slack.com
Desc: real-time messaging
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
}
username = from_unicode(kwargs.pop("us... | python | def send(channel, message, **kwargs):
"""
Site: https://slack.com
API: https://api.slack.com
Desc: real-time messaging
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
}
username = from_unicode(kwargs.pop("us... | [
"def",
"send",
"(",
"channel",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"}",
"usern... | Site: https://slack.com
API: https://api.slack.com
Desc: real-time messaging | [
"Site",
":",
"https",
":",
"//",
"slack",
".",
"com",
"API",
":",
"https",
":",
"//",
"api",
".",
"slack",
".",
"com",
"Desc",
":",
"real",
"-",
"time",
"messaging"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/slack/push.py#L23-L65 |
LPgenerator/django-db-mailer | dbmail/providers/smsaero/sms.py | send | def send(sms_to, sms_body, **kwargs):
"""
Site: http://smsaero.ru/
API: http://smsaero.ru/api/
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
}
kwargs.update({
'user': settings.SMSAERO_LOGIN,
'password': settings.SMSAERO_MD5_PASSWORD,
'from': kwar... | python | def send(sms_to, sms_body, **kwargs):
"""
Site: http://smsaero.ru/
API: http://smsaero.ru/api/
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
}
kwargs.update({
'user': settings.SMSAERO_LOGIN,
'password': settings.SMSAERO_MD5_PASSWORD,
'from': kwar... | [
"def",
"send",
"(",
"sms_to",
",",
"sms_body",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"}",
"kwargs",
".",
"update",
"(",
"{",
"'user'",
":",
"settings",
".",
... | Site: http://smsaero.ru/
API: http://smsaero.ru/api/ | [
"Site",
":",
"http",
":",
"//",
"smsaero",
".",
"ru",
"/",
"API",
":",
"http",
":",
"//",
"smsaero",
".",
"ru",
"/",
"api",
"/"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/smsaero/sms.py#L23-L61 |
LPgenerator/django-db-mailer | dbmail/providers/sendinblue/mail.py | email_list_to_email_dict | def email_list_to_email_dict(email_list):
"""Convert a list of email to a dict of email."""
if email_list is None:
return {}
result = {}
for value in email_list:
realname, address = email.utils.parseaddr(value)
result[address] = realname if realname and address else address
r... | python | def email_list_to_email_dict(email_list):
"""Convert a list of email to a dict of email."""
if email_list is None:
return {}
result = {}
for value in email_list:
realname, address = email.utils.parseaddr(value)
result[address] = realname if realname and address else address
r... | [
"def",
"email_list_to_email_dict",
"(",
"email_list",
")",
":",
"if",
"email_list",
"is",
"None",
":",
"return",
"{",
"}",
"result",
"=",
"{",
"}",
"for",
"value",
"in",
"email_list",
":",
"realname",
",",
"address",
"=",
"email",
".",
"utils",
".",
"par... | Convert a list of email to a dict of email. | [
"Convert",
"a",
"list",
"of",
"email",
"to",
"a",
"dict",
"of",
"email",
"."
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/sendinblue/mail.py#L15-L23 |
LPgenerator/django-db-mailer | dbmail/providers/sendinblue/mail.py | email_address_to_list | def email_address_to_list(email_address):
"""Convert an email address to a list."""
realname, address = email.utils.parseaddr(email_address)
return (
[address, realname] if realname and address else
[email_address, email_address]
) | python | def email_address_to_list(email_address):
"""Convert an email address to a list."""
realname, address = email.utils.parseaddr(email_address)
return (
[address, realname] if realname and address else
[email_address, email_address]
) | [
"def",
"email_address_to_list",
"(",
"email_address",
")",
":",
"realname",
",",
"address",
"=",
"email",
".",
"utils",
".",
"parseaddr",
"(",
"email_address",
")",
"return",
"(",
"[",
"address",
",",
"realname",
"]",
"if",
"realname",
"and",
"address",
"els... | Convert an email address to a list. | [
"Convert",
"an",
"email",
"address",
"to",
"a",
"list",
"."
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/sendinblue/mail.py#L26-L32 |
LPgenerator/django-db-mailer | dbmail/providers/sendinblue/mail.py | send | def send(sender_instance):
"""Send a transactional email using SendInBlue API.
Site: https://www.sendinblue.com
API: https://apidocs.sendinblue.com/
"""
m = Mailin(
"https://api.sendinblue.com/v2.0",
sender_instance._kwargs.get("api_key")
)
data = {
"to": email_list_... | python | def send(sender_instance):
"""Send a transactional email using SendInBlue API.
Site: https://www.sendinblue.com
API: https://apidocs.sendinblue.com/
"""
m = Mailin(
"https://api.sendinblue.com/v2.0",
sender_instance._kwargs.get("api_key")
)
data = {
"to": email_list_... | [
"def",
"send",
"(",
"sender_instance",
")",
":",
"m",
"=",
"Mailin",
"(",
"\"https://api.sendinblue.com/v2.0\"",
",",
"sender_instance",
".",
"_kwargs",
".",
"get",
"(",
"\"api_key\"",
")",
")",
"data",
"=",
"{",
"\"to\"",
":",
"email_list_to_email_dict",
"(",
... | Send a transactional email using SendInBlue API.
Site: https://www.sendinblue.com
API: https://apidocs.sendinblue.com/ | [
"Send",
"a",
"transactional",
"email",
"using",
"SendInBlue",
"API",
"."
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/sendinblue/mail.py#L35-L65 |
LPgenerator/django-db-mailer | dbmail/providers/iqsms/sms.py | send | def send(sms_to, sms_body, **kwargs):
"""
Site: http://iqsms.ru/
API: http://iqsms.ru/api/
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
'Authorization': 'Basic %s' % b64encode(
"%s:%s" % (
settings.IQSMS_API_LOGIN, settings.IQSMS_API_PASSWORD... | python | def send(sms_to, sms_body, **kwargs):
"""
Site: http://iqsms.ru/
API: http://iqsms.ru/api/
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
'Authorization': 'Basic %s' % b64encode(
"%s:%s" % (
settings.IQSMS_API_LOGIN, settings.IQSMS_API_PASSWORD... | [
"def",
"send",
"(",
"sms_to",
",",
"sms_body",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"'Authorization'",
":",
"'Basic %s'",
"%",
"b64encode",
"(",
"\"%s:%s\"",
"%",... | Site: http://iqsms.ru/
API: http://iqsms.ru/api/ | [
"Site",
":",
"http",
":",
"//",
"iqsms",
".",
"ru",
"/",
"API",
":",
"http",
":",
"//",
"iqsms",
".",
"ru",
"/",
"api",
"/"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/iqsms/sms.py#L22-L52 |
LPgenerator/django-db-mailer | dbmail/providers/parse_com/push.py | send | def send(device_id, description, **kwargs):
"""
Site: http://parse.com
API: https://www.parse.com/docs/push_guide#scheduled/REST
Desc: Best app for system administrators
"""
headers = {
"X-Parse-Application-Id": settings.PARSE_APP_ID,
"X-Parse-REST-API-Key": settings.PARSE_API_KE... | python | def send(device_id, description, **kwargs):
"""
Site: http://parse.com
API: https://www.parse.com/docs/push_guide#scheduled/REST
Desc: Best app for system administrators
"""
headers = {
"X-Parse-Application-Id": settings.PARSE_APP_ID,
"X-Parse-REST-API-Key": settings.PARSE_API_KE... | [
"def",
"send",
"(",
"device_id",
",",
"description",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"X-Parse-Application-Id\"",
":",
"settings",
".",
"PARSE_APP_ID",
",",
"\"X-Parse-REST-API-Key\"",
":",
"settings",
".",
"PARSE_API_KEY",
",",
"\"User-... | Site: http://parse.com
API: https://www.parse.com/docs/push_guide#scheduled/REST
Desc: Best app for system administrators | [
"Site",
":",
"http",
":",
"//",
"parse",
".",
"com",
"API",
":",
"https",
":",
"//",
"www",
".",
"parse",
".",
"com",
"/",
"docs",
"/",
"push_guide#scheduled",
"/",
"REST",
"Desc",
":",
"Best",
"app",
"for",
"system",
"administrators"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/parse_com/push.py#L19-L59 |
LPgenerator/django-db-mailer | dbmail/providers/prowl/push.py | send | def send(api_key, description, **kwargs):
"""
Site: http://prowlapp.com
API: http://prowlapp.com/api.php
Desc: Best app for system administrators
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
"Content-type": "application/x-www-form-urlencoded"
}
application ... | python | def send(api_key, description, **kwargs):
"""
Site: http://prowlapp.com
API: http://prowlapp.com/api.php
Desc: Best app for system administrators
"""
headers = {
"User-Agent": "DBMail/%s" % get_version(),
"Content-type": "application/x-www-form-urlencoded"
}
application ... | [
"def",
"send",
"(",
"api_key",
",",
"description",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
"}",
"applicat... | Site: http://prowlapp.com
API: http://prowlapp.com/api.php
Desc: Best app for system administrators | [
"Site",
":",
"http",
":",
"//",
"prowlapp",
".",
"com",
"API",
":",
"http",
":",
"//",
"prowlapp",
".",
"com",
"/",
"api",
".",
"php",
"Desc",
":",
"Best",
"app",
"for",
"system",
"administrators"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/prowl/push.py#L30-L71 |
LPgenerator/django-db-mailer | dbmail/providers/apple/apns.py | send | def send(token_hex, message, **kwargs):
"""
Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications
"""
is_enhanced = kwargs.pop('is_enhanced', False)
identifier = kwargs.pop('identifier', 0)
expiry = kwargs.pop('expiry', 0)
alert = {
"title": kwargs... | python | def send(token_hex, message, **kwargs):
"""
Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications
"""
is_enhanced = kwargs.pop('is_enhanced', False)
identifier = kwargs.pop('identifier', 0)
expiry = kwargs.pop('expiry', 0)
alert = {
"title": kwargs... | [
"def",
"send",
"(",
"token_hex",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"is_enhanced",
"=",
"kwargs",
".",
"pop",
"(",
"'is_enhanced'",
",",
"False",
")",
"identifier",
"=",
"kwargs",
".",
"pop",
"(",
"'identifier'",
",",
"0",
")",
"expiry"... | Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications | [
"Site",
":",
"https",
":",
"//",
"apple",
".",
"com",
"API",
":",
"https",
":",
"//",
"developer",
".",
"apple",
".",
"com",
"Desc",
":",
"iOS",
"notifications"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/apple/apns.py#L21-L79 |
LPgenerator/django-db-mailer | dbmail/providers/pushall/push.py | send | def send(ch, message, **kwargs):
"""
Site: https://pushall.ru
API: https://pushall.ru/blog/api
Desc: App for notification to devices/browsers and messaging apps
"""
params = {
'type': kwargs.pop('req_type', 'self'),
'key': settings.PUSHALL_API_KEYS[ch]['key'],
'id': setti... | python | def send(ch, message, **kwargs):
"""
Site: https://pushall.ru
API: https://pushall.ru/blog/api
Desc: App for notification to devices/browsers and messaging apps
"""
params = {
'type': kwargs.pop('req_type', 'self'),
'key': settings.PUSHALL_API_KEYS[ch]['key'],
'id': setti... | [
"def",
"send",
"(",
"ch",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'type'",
":",
"kwargs",
".",
"pop",
"(",
"'req_type'",
",",
"'self'",
")",
",",
"'key'",
":",
"settings",
".",
"PUSHALL_API_KEYS",
"[",
"ch",
"]",
"["... | Site: https://pushall.ru
API: https://pushall.ru/blog/api
Desc: App for notification to devices/browsers and messaging apps | [
"Site",
":",
"https",
":",
"//",
"pushall",
".",
"ru",
"API",
":",
"https",
":",
"//",
"pushall",
".",
"ru",
"/",
"blog",
"/",
"api",
"Desc",
":",
"App",
"for",
"notification",
"to",
"devices",
"/",
"browsers",
"and",
"messaging",
"apps"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/pushall/push.py#L14-L46 |
LPgenerator/django-db-mailer | dbmail/providers/telegram/bot.py | send | def send(to, message, **kwargs):
"""
SITE: https://github.com/nickoala/telepot
TELEGRAM API: https://core.telegram.org/bots/api
Installation:
pip install 'telepot>=10.4'
"""
available_kwargs_keys = [
'parse_mode',
'disable_web_page_preview',
'disable_noti... | python | def send(to, message, **kwargs):
"""
SITE: https://github.com/nickoala/telepot
TELEGRAM API: https://core.telegram.org/bots/api
Installation:
pip install 'telepot>=10.4'
"""
available_kwargs_keys = [
'parse_mode',
'disable_web_page_preview',
'disable_noti... | [
"def",
"send",
"(",
"to",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"available_kwargs_keys",
"=",
"[",
"'parse_mode'",
",",
"'disable_web_page_preview'",
",",
"'disable_notification'",
",",
"'reply_to_message_id'",
",",
"'reply_markup'",
"]",
"available_kwa... | SITE: https://github.com/nickoala/telepot
TELEGRAM API: https://core.telegram.org/bots/api
Installation:
pip install 'telepot>=10.4' | [
"SITE",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"nickoala",
"/",
"telepot",
"TELEGRAM",
"API",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/telegram/bot.py#L7-L29 |
LPgenerator/django-db-mailer | dbmail/providers/google/browser.py | send | def send(reg_id, message, **kwargs):
"""
Site: https://developers.google.com
API: https://developers.google.com/web/updates/2016/03/web-push-encryption
Desc: Web Push notifications for Chrome and FireFox
Installation:
pip install 'pywebpush>=0.4.0'
"""
subscription_info = kwargs.pop('s... | python | def send(reg_id, message, **kwargs):
"""
Site: https://developers.google.com
API: https://developers.google.com/web/updates/2016/03/web-push-encryption
Desc: Web Push notifications for Chrome and FireFox
Installation:
pip install 'pywebpush>=0.4.0'
"""
subscription_info = kwargs.pop('s... | [
"def",
"send",
"(",
"reg_id",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"subscription_info",
"=",
"kwargs",
".",
"pop",
"(",
"'subscription_info'",
")",
"payload",
"=",
"{",
"\"title\"",
":",
"kwargs",
".",
"pop",
"(",
"\"event\"",
")",
",",
"... | Site: https://developers.google.com
API: https://developers.google.com/web/updates/2016/03/web-push-encryption
Desc: Web Push notifications for Chrome and FireFox
Installation:
pip install 'pywebpush>=0.4.0' | [
"Site",
":",
"https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"API",
":",
"https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"web",
"/",
"updates",
"/",
"2016",
"/",
"03",
"/",
"web",
"-",
"push",
"-",
"encryption",
"Desc... | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/google/browser.py#L13-L40 |
LPgenerator/django-db-mailer | dbmail/providers/apple/apns2.py | send | def send(token_hex, message, **kwargs):
"""
Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications
Installation and usage:
pip install hyper
"""
priority = kwargs.pop('priority', 10)
topic = kwargs.pop('topic', None)
alert = {
"title": kwargs.... | python | def send(token_hex, message, **kwargs):
"""
Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications
Installation and usage:
pip install hyper
"""
priority = kwargs.pop('priority', 10)
topic = kwargs.pop('topic', None)
alert = {
"title": kwargs.... | [
"def",
"send",
"(",
"token_hex",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"priority",
"=",
"kwargs",
".",
"pop",
"(",
"'priority'",
",",
"10",
")",
"topic",
"=",
"kwargs",
".",
"pop",
"(",
"'topic'",
",",
"None",
")",
"alert",
"=",
"{",
... | Site: https://apple.com
API: https://developer.apple.com
Desc: iOS notifications
Installation and usage:
pip install hyper | [
"Site",
":",
"https",
":",
"//",
"apple",
".",
"com",
"API",
":",
"https",
":",
"//",
"developer",
".",
"apple",
".",
"com",
"Desc",
":",
"iOS",
"notifications"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/apple/apns2.py#L11-L56 |
LPgenerator/django-db-mailer | dbmail/providers/twilio/sms.py | send | def send(sms_to, sms_body, **kwargs):
"""
Site: https://www.twilio.com/
API: https://www.twilio.com/docs/api/rest/sending-messages
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
'Authorization': 'Basic %s' % b64... | python | def send(sms_to, sms_body, **kwargs):
"""
Site: https://www.twilio.com/
API: https://www.twilio.com/docs/api/rest/sending-messages
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
'Authorization': 'Basic %s' % b64... | [
"def",
"send",
"(",
"sms_to",
",",
"sms_body",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"'Authorizati... | Site: https://www.twilio.com/
API: https://www.twilio.com/docs/api/rest/sending-messages | [
"Site",
":",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"API",
":",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"rest",
"/",
"sending",
"-",
"messages"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/twilio/sms.py#L23-L55 |
LPgenerator/django-db-mailer | dbmail/providers/pushover/push.py | send | def send(user, message, **kwargs):
"""
Site: https://pushover.net/
API: https://pushover.net/api
Desc: real-time notifications
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
}
title = from_unicode(kwargs.po... | python | def send(user, message, **kwargs):
"""
Site: https://pushover.net/
API: https://pushover.net/api
Desc: real-time notifications
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),
}
title = from_unicode(kwargs.po... | [
"def",
"send",
"(",
"user",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"}",
"title",
... | Site: https://pushover.net/
API: https://pushover.net/api
Desc: real-time notifications | [
"Site",
":",
"https",
":",
"//",
"pushover",
".",
"net",
"/",
"API",
":",
"https",
":",
"//",
"pushover",
".",
"net",
"/",
"api",
"Desc",
":",
"real",
"-",
"time",
"notifications"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/pushover/push.py#L22-L61 |
LPgenerator/django-db-mailer | dbmail/providers/google/android.py | send | def send(user, message, **kwargs):
"""
Site: https://developers.google.com
API: https://developers.google.com/cloud-messaging/
Desc: Android notifications
"""
headers = {
"Content-type": "application/json",
"Authorization": "key=" + kwargs.pop("gcm_key", settings.GCM_KEY)
}
... | python | def send(user, message, **kwargs):
"""
Site: https://developers.google.com
API: https://developers.google.com/cloud-messaging/
Desc: Android notifications
"""
headers = {
"Content-type": "application/json",
"Authorization": "key=" + kwargs.pop("gcm_key", settings.GCM_KEY)
}
... | [
"def",
"send",
"(",
"user",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/json\"",
",",
"\"Authorization\"",
":",
"\"key=\"",
"+",
"kwargs",
".",
"pop",
"(",
"\"gcm_key\"",
",",
"settings",
... | Site: https://developers.google.com
API: https://developers.google.com/cloud-messaging/
Desc: Android notifications | [
"Site",
":",
"https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"API",
":",
"https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"cloud",
"-",
"messaging",
"/",
"Desc",
":",
"Android",
"notifications"
] | train | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/google/android.py#L18-L55 |
g2p/blocks | blocks/__main__.py | rotate_lv | def rotate_lv(*, device, size, debug, forward):
"""Rotate a logical volume by a single PE.
If forward:
Move the first physical extent of an LV to the end
else:
Move the last physical extent of a LV to the start
then poke LVM to refresh the mapping.
"""
import augeas
class ... | python | def rotate_lv(*, device, size, debug, forward):
"""Rotate a logical volume by a single PE.
If forward:
Move the first physical extent of an LV to the end
else:
Move the last physical extent of a LV to the start
then poke LVM to refresh the mapping.
"""
import augeas
class ... | [
"def",
"rotate_lv",
"(",
"*",
",",
"device",
",",
"size",
",",
"debug",
",",
"forward",
")",
":",
"import",
"augeas",
"class",
"Augeas",
"(",
"augeas",
".",
"Augeas",
")",
":",
"def",
"get_int",
"(",
"self",
",",
"key",
")",
":",
"return",
"int",
"... | Rotate a logical volume by a single PE.
If forward:
Move the first physical extent of an LV to the end
else:
Move the last physical extent of a LV to the start
then poke LVM to refresh the mapping. | [
"Rotate",
"a",
"logical",
"volume",
"by",
"a",
"single",
"PE",
"."
] | train | https://github.com/g2p/blocks/blob/d00d8aa2bcb64ef5113de9500220e57049b836b4/blocks/__main__.py#L1380-L1478 |
jaseg/python-mpv | mpv.py | _mpv_coax_proptype | def _mpv_coax_proptype(value, proptype=str):
"""Intelligently coax the given python value into something that can be understood as a proptype property."""
if type(value) is bytes:
return value;
elif type(value) is bool:
return b'yes' if value else b'no'
elif proptype in (str, int, float)... | python | def _mpv_coax_proptype(value, proptype=str):
"""Intelligently coax the given python value into something that can be understood as a proptype property."""
if type(value) is bytes:
return value;
elif type(value) is bool:
return b'yes' if value else b'no'
elif proptype in (str, int, float)... | [
"def",
"_mpv_coax_proptype",
"(",
"value",
",",
"proptype",
"=",
"str",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"bytes",
":",
"return",
"value",
"elif",
"type",
"(",
"value",
")",
"is",
"bool",
":",
"return",
"b'yes'",
"if",
"value",
"else",
... | Intelligently coax the given python value into something that can be understood as a proptype property. | [
"Intelligently",
"coax",
"the",
"given",
"python",
"value",
"into",
"something",
"that",
"can",
"be",
"understood",
"as",
"a",
"proptype",
"property",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L400-L409 |
jaseg/python-mpv | mpv.py | _make_node_str_list | def _make_node_str_list(l):
"""Take a list of python objects and make a MPV string node array from it.
As an example, the python list ``l = [ "foo", 23, false ]`` will result in the following MPV node object::
struct mpv_node {
.format = MPV_NODE_ARRAY,
.u.list = *(struct mpv_n... | python | def _make_node_str_list(l):
"""Take a list of python objects and make a MPV string node array from it.
As an example, the python list ``l = [ "foo", 23, false ]`` will result in the following MPV node object::
struct mpv_node {
.format = MPV_NODE_ARRAY,
.u.list = *(struct mpv_n... | [
"def",
"_make_node_str_list",
"(",
"l",
")",
":",
"char_ps",
"=",
"[",
"c_char_p",
"(",
"_mpv_coax_proptype",
"(",
"e",
",",
"str",
")",
")",
"for",
"e",
"in",
"l",
"]",
"node_list",
"=",
"MpvNodeList",
"(",
"num",
"=",
"len",
"(",
"l",
")",
",",
"... | Take a list of python objects and make a MPV string node array from it.
As an example, the python list ``l = [ "foo", 23, false ]`` will result in the following MPV node object::
struct mpv_node {
.format = MPV_NODE_ARRAY,
.u.list = *(struct mpv_node_array){
.num = ... | [
"Take",
"a",
"list",
"of",
"python",
"objects",
"and",
"make",
"a",
"MPV",
"string",
"node",
"array",
"from",
"it",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L411-L440 |
jaseg/python-mpv | mpv.py | MPV.wait_for_property | def wait_for_property(self, name, cond=lambda val: val, level_sensitive=True):
"""Waits until ``cond`` evaluates to a truthy value on the named property. This can be used to wait for
properties such as ``idle_active`` indicating the player is done with regular playback and just idling around
"""... | python | def wait_for_property(self, name, cond=lambda val: val, level_sensitive=True):
"""Waits until ``cond`` evaluates to a truthy value on the named property. This can be used to wait for
properties such as ``idle_active`` indicating the player is done with regular playback and just idling around
"""... | [
"def",
"wait_for_property",
"(",
"self",
",",
"name",
",",
"cond",
"=",
"lambda",
"val",
":",
"val",
",",
"level_sensitive",
"=",
"True",
")",
":",
"sema",
"=",
"threading",
".",
"Semaphore",
"(",
"value",
"=",
"0",
")",
"def",
"observer",
"(",
"name",... | Waits until ``cond`` evaluates to a truthy value on the named property. This can be used to wait for
properties such as ``idle_active`` indicating the player is done with regular playback and just idling around | [
"Waits",
"until",
"cond",
"evaluates",
"to",
"a",
"truthy",
"value",
"on",
"the",
"named",
"property",
".",
"This",
"can",
"be",
"used",
"to",
"wait",
"for",
"properties",
"such",
"as",
"idle_active",
"indicating",
"the",
"player",
"is",
"done",
"with",
"r... | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L582-L593 |
jaseg/python-mpv | mpv.py | MPV.terminate | def terminate(self):
"""Properly terminates this player instance. Preferably use this instead of relying on python's garbage
collector to cause this to be called from the object's destructor.
"""
self.handle, handle = None, self.handle
if threading.current_thread() is self._event... | python | def terminate(self):
"""Properly terminates this player instance. Preferably use this instead of relying on python's garbage
collector to cause this to be called from the object's destructor.
"""
self.handle, handle = None, self.handle
if threading.current_thread() is self._event... | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"handle",
",",
"handle",
"=",
"None",
",",
"self",
".",
"handle",
"if",
"threading",
".",
"current_thread",
"(",
")",
"is",
"self",
".",
"_event_thread",
":",
"# Handle special case to allow event handle ... | Properly terminates this player instance. Preferably use this instead of relying on python's garbage
collector to cause this to be called from the object's destructor. | [
"Properly",
"terminates",
"this",
"player",
"instance",
".",
"Preferably",
"use",
"this",
"instead",
"of",
"relying",
"on",
"python",
"s",
"garbage",
"collector",
"to",
"cause",
"this",
"to",
"be",
"called",
"from",
"the",
"object",
"s",
"destructor",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L599-L612 |
jaseg/python-mpv | mpv.py | MPV.command | def command(self, name, *args):
"""Execute a raw command."""
args = [name.encode('utf-8')] + [ (arg if type(arg) is bytes else str(arg).encode('utf-8'))
for arg in args if arg is not None ] + [None]
_mpv_command(self.handle, (c_char_p*len(args))(*args)) | python | def command(self, name, *args):
"""Execute a raw command."""
args = [name.encode('utf-8')] + [ (arg if type(arg) is bytes else str(arg).encode('utf-8'))
for arg in args if arg is not None ] + [None]
_mpv_command(self.handle, (c_char_p*len(args))(*args)) | [
"def",
"command",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"args",
"=",
"[",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
"]",
"+",
"[",
"(",
"arg",
"if",
"type",
"(",
"arg",
")",
"is",
"bytes",
"else",
"str",
"(",
"arg",
")",
"."... | Execute a raw command. | [
"Execute",
"a",
"raw",
"command",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L624-L628 |
jaseg/python-mpv | mpv.py | MPV.seek | def seek(self, amount, reference="relative", precision="default-precise"):
"""Mapped mpv seek command, see man mpv(1)."""
self.command('seek', amount, reference, precision) | python | def seek(self, amount, reference="relative", precision="default-precise"):
"""Mapped mpv seek command, see man mpv(1)."""
self.command('seek', amount, reference, precision) | [
"def",
"seek",
"(",
"self",
",",
"amount",
",",
"reference",
"=",
"\"relative\"",
",",
"precision",
"=",
"\"default-precise\"",
")",
":",
"self",
".",
"command",
"(",
"'seek'",
",",
"amount",
",",
"reference",
",",
"precision",
")"
] | Mapped mpv seek command, see man mpv(1). | [
"Mapped",
"mpv",
"seek",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L639-L641 |
jaseg/python-mpv | mpv.py | MPV.screenshot_to_file | def screenshot_to_file(self, filename, includes='subtitles'):
"""Mapped mpv screenshot_to_file command, see man mpv(1)."""
self.command('screenshot_to_file', filename.encode(fs_enc), includes) | python | def screenshot_to_file(self, filename, includes='subtitles'):
"""Mapped mpv screenshot_to_file command, see man mpv(1)."""
self.command('screenshot_to_file', filename.encode(fs_enc), includes) | [
"def",
"screenshot_to_file",
"(",
"self",
",",
"filename",
",",
"includes",
"=",
"'subtitles'",
")",
":",
"self",
".",
"command",
"(",
"'screenshot_to_file'",
",",
"filename",
".",
"encode",
"(",
"fs_enc",
")",
",",
"includes",
")"
] | Mapped mpv screenshot_to_file command, see man mpv(1). | [
"Mapped",
"mpv",
"screenshot_to_file",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L675-L677 |
jaseg/python-mpv | mpv.py | MPV.screenshot_raw | def screenshot_raw(self, includes='subtitles'):
"""Mapped mpv screenshot_raw command, see man mpv(1). Returns a pillow Image object."""
from PIL import Image
res = self.node_command('screenshot-raw', includes)
if res['format'] != 'bgr0':
raise ValueError('Screenshot in unknow... | python | def screenshot_raw(self, includes='subtitles'):
"""Mapped mpv screenshot_raw command, see man mpv(1). Returns a pillow Image object."""
from PIL import Image
res = self.node_command('screenshot-raw', includes)
if res['format'] != 'bgr0':
raise ValueError('Screenshot in unknow... | [
"def",
"screenshot_raw",
"(",
"self",
",",
"includes",
"=",
"'subtitles'",
")",
":",
"from",
"PIL",
"import",
"Image",
"res",
"=",
"self",
".",
"node_command",
"(",
"'screenshot-raw'",
",",
"includes",
")",
"if",
"res",
"[",
"'format'",
"]",
"!=",
"'bgr0'"... | Mapped mpv screenshot_raw command, see man mpv(1). Returns a pillow Image object. | [
"Mapped",
"mpv",
"screenshot_raw",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
".",
"Returns",
"a",
"pillow",
"Image",
"object",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L679-L688 |
jaseg/python-mpv | mpv.py | MPV.loadfile | def loadfile(self, filename, mode='replace', **options):
"""Mapped mpv loadfile command, see man mpv(1)."""
self.command('loadfile', filename.encode(fs_enc), mode, MPV._encode_options(options)) | python | def loadfile(self, filename, mode='replace', **options):
"""Mapped mpv loadfile command, see man mpv(1)."""
self.command('loadfile', filename.encode(fs_enc), mode, MPV._encode_options(options)) | [
"def",
"loadfile",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'replace'",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"command",
"(",
"'loadfile'",
",",
"filename",
".",
"encode",
"(",
"fs_enc",
")",
",",
"mode",
",",
"MPV",
".",
"_encode_... | Mapped mpv loadfile command, see man mpv(1). | [
"Mapped",
"mpv",
"loadfile",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L702-L704 |
jaseg/python-mpv | mpv.py | MPV.loadlist | def loadlist(self, playlist, mode='replace'):
"""Mapped mpv loadlist command, see man mpv(1)."""
self.command('loadlist', playlist.encode(fs_enc), mode) | python | def loadlist(self, playlist, mode='replace'):
"""Mapped mpv loadlist command, see man mpv(1)."""
self.command('loadlist', playlist.encode(fs_enc), mode) | [
"def",
"loadlist",
"(",
"self",
",",
"playlist",
",",
"mode",
"=",
"'replace'",
")",
":",
"self",
".",
"command",
"(",
"'loadlist'",
",",
"playlist",
".",
"encode",
"(",
"fs_enc",
")",
",",
"mode",
")"
] | Mapped mpv loadlist command, see man mpv(1). | [
"Mapped",
"mpv",
"loadlist",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L706-L708 |
jaseg/python-mpv | mpv.py | MPV.overlay_add | def overlay_add(self, overlay_id, x, y, file_or_fd, offset, fmt, w, h, stride):
"""Mapped mpv overlay_add command, see man mpv(1)."""
self.command('overlay_add', overlay_id, x, y, file_or_fd, offset, fmt, w, h, stride) | python | def overlay_add(self, overlay_id, x, y, file_or_fd, offset, fmt, w, h, stride):
"""Mapped mpv overlay_add command, see man mpv(1)."""
self.command('overlay_add', overlay_id, x, y, file_or_fd, offset, fmt, w, h, stride) | [
"def",
"overlay_add",
"(",
"self",
",",
"overlay_id",
",",
"x",
",",
"y",
",",
"file_or_fd",
",",
"offset",
",",
"fmt",
",",
"w",
",",
"h",
",",
"stride",
")",
":",
"self",
".",
"command",
"(",
"'overlay_add'",
",",
"overlay_id",
",",
"x",
",",
"y"... | Mapped mpv overlay_add command, see man mpv(1). | [
"Mapped",
"mpv",
"overlay_add",
"command",
"see",
"man",
"mpv",
"(",
"1",
")",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L774-L776 |
jaseg/python-mpv | mpv.py | MPV.observe_property | def observe_property(self, name, handler):
"""Register an observer on the named property. An observer is a function that is called with the new property
value every time the property's value is changed. The basic function signature is ``fun(property_name,
new_value)`` with new_value being the de... | python | def observe_property(self, name, handler):
"""Register an observer on the named property. An observer is a function that is called with the new property
value every time the property's value is changed. The basic function signature is ``fun(property_name,
new_value)`` with new_value being the de... | [
"def",
"observe_property",
"(",
"self",
",",
"name",
",",
"handler",
")",
":",
"self",
".",
"_property_handlers",
"[",
"name",
"]",
".",
"append",
"(",
"handler",
")",
"_mpv_observe_property",
"(",
"self",
".",
"_event_handle",
",",
"hash",
"(",
"name",
")... | Register an observer on the named property. An observer is a function that is called with the new property
value every time the property's value is changed. The basic function signature is ``fun(property_name,
new_value)`` with new_value being the decoded property value as a python object. This function... | [
"Register",
"an",
"observer",
"on",
"the",
"named",
"property",
".",
"An",
"observer",
"is",
"a",
"function",
"that",
"is",
"called",
"with",
"the",
"new",
"property",
"value",
"every",
"time",
"the",
"property",
"s",
"value",
"is",
"changed",
".",
"The",
... | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L790-L806 |
jaseg/python-mpv | mpv.py | MPV.property_observer | def property_observer(self, name):
"""Function decorator to register a property observer. See ``MPV.observe_property`` for details."""
def wrapper(fun):
self.observe_property(name, fun)
fun.unobserve_mpv_properties = lambda: self.unobserve_property(name, fun)
return f... | python | def property_observer(self, name):
"""Function decorator to register a property observer. See ``MPV.observe_property`` for details."""
def wrapper(fun):
self.observe_property(name, fun)
fun.unobserve_mpv_properties = lambda: self.unobserve_property(name, fun)
return f... | [
"def",
"property_observer",
"(",
"self",
",",
"name",
")",
":",
"def",
"wrapper",
"(",
"fun",
")",
":",
"self",
".",
"observe_property",
"(",
"name",
",",
"fun",
")",
"fun",
".",
"unobserve_mpv_properties",
"=",
"lambda",
":",
"self",
".",
"unobserve_prope... | Function decorator to register a property observer. See ``MPV.observe_property`` for details. | [
"Function",
"decorator",
"to",
"register",
"a",
"property",
"observer",
".",
"See",
"MPV",
".",
"observe_property",
"for",
"details",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L808-L814 |
jaseg/python-mpv | mpv.py | MPV.unobserve_property | def unobserve_property(self, name, handler):
"""Unregister a property observer. This requires both the observed property's name and the handler function that
was originally registered as one handler could be registered for several properties. To unregister a handler
from *all* observed propertie... | python | def unobserve_property(self, name, handler):
"""Unregister a property observer. This requires both the observed property's name and the handler function that
was originally registered as one handler could be registered for several properties. To unregister a handler
from *all* observed propertie... | [
"def",
"unobserve_property",
"(",
"self",
",",
"name",
",",
"handler",
")",
":",
"self",
".",
"_property_handlers",
"[",
"name",
"]",
".",
"remove",
"(",
"handler",
")",
"if",
"not",
"self",
".",
"_property_handlers",
"[",
"name",
"]",
":",
"_mpv_unobserve... | Unregister a property observer. This requires both the observed property's name and the handler function that
was originally registered as one handler could be registered for several properties. To unregister a handler
from *all* observed properties see ``unobserve_all_properties``. | [
"Unregister",
"a",
"property",
"observer",
".",
"This",
"requires",
"both",
"the",
"observed",
"property",
"s",
"name",
"and",
"the",
"handler",
"function",
"that",
"was",
"originally",
"registered",
"as",
"one",
"handler",
"could",
"be",
"registered",
"for",
... | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L816-L823 |
jaseg/python-mpv | mpv.py | MPV.unobserve_all_properties | def unobserve_all_properties(self, handler):
"""Unregister a property observer from *all* observed properties."""
for name in self._property_handlers:
self.unobserve_property(name, handler) | python | def unobserve_all_properties(self, handler):
"""Unregister a property observer from *all* observed properties."""
for name in self._property_handlers:
self.unobserve_property(name, handler) | [
"def",
"unobserve_all_properties",
"(",
"self",
",",
"handler",
")",
":",
"for",
"name",
"in",
"self",
".",
"_property_handlers",
":",
"self",
".",
"unobserve_property",
"(",
"name",
",",
"handler",
")"
] | Unregister a property observer from *all* observed properties. | [
"Unregister",
"a",
"property",
"observer",
"from",
"*",
"all",
"*",
"observed",
"properties",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L825-L828 |
jaseg/python-mpv | mpv.py | MPV.unregister_message_handler | def unregister_message_handler(self, target_or_handler):
"""Unregister a mpv script message handler for the given script message target name.
You can also call the ``unregister_mpv_messages`` function attribute set on the handler function when it is
registered.
"""
if isinstance... | python | def unregister_message_handler(self, target_or_handler):
"""Unregister a mpv script message handler for the given script message target name.
You can also call the ``unregister_mpv_messages`` function attribute set on the handler function when it is
registered.
"""
if isinstance... | [
"def",
"unregister_message_handler",
"(",
"self",
",",
"target_or_handler",
")",
":",
"if",
"isinstance",
"(",
"target_or_handler",
",",
"str",
")",
":",
"del",
"self",
".",
"_message_handlers",
"[",
"target_or_handler",
"]",
"else",
":",
"for",
"key",
",",
"v... | Unregister a mpv script message handler for the given script message target name.
You can also call the ``unregister_mpv_messages`` function attribute set on the handler function when it is
registered. | [
"Unregister",
"a",
"mpv",
"script",
"message",
"handler",
"for",
"the",
"given",
"script",
"message",
"target",
"name",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L850-L861 |
jaseg/python-mpv | mpv.py | MPV.message_handler | def message_handler(self, target):
"""Decorator to register a mpv script message handler.
WARNING: Only one handler can be registered at a time for any given target.
To unregister the message handler, call its ``unregister_mpv_messages`` function::
player = mpv.MPV()
@... | python | def message_handler(self, target):
"""Decorator to register a mpv script message handler.
WARNING: Only one handler can be registered at a time for any given target.
To unregister the message handler, call its ``unregister_mpv_messages`` function::
player = mpv.MPV()
@... | [
"def",
"message_handler",
"(",
"self",
",",
"target",
")",
":",
"def",
"register",
"(",
"handler",
")",
":",
"self",
".",
"_register_message_handler_internal",
"(",
"target",
",",
"handler",
")",
"handler",
".",
"unregister_mpv_messages",
"=",
"lambda",
":",
"... | Decorator to register a mpv script message handler.
WARNING: Only one handler can be registered at a time for any given target.
To unregister the message handler, call its ``unregister_mpv_messages`` function::
player = mpv.MPV()
@player.message_handler('foo')
def ... | [
"Decorator",
"to",
"register",
"a",
"mpv",
"script",
"message",
"handler",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L863-L881 |
jaseg/python-mpv | mpv.py | MPV.event_callback | def event_callback(self, *event_types):
"""Function decorator to register a blanket event callback for the given event types. Event types can be given
as str (e.g. 'start-file'), integer or MpvEventID object.
WARNING: Due to the way this is filtering events, this decorator cannot be chained wi... | python | def event_callback(self, *event_types):
"""Function decorator to register a blanket event callback for the given event types. Event types can be given
as str (e.g. 'start-file'), integer or MpvEventID object.
WARNING: Due to the way this is filtering events, this decorator cannot be chained wi... | [
"def",
"event_callback",
"(",
"self",
",",
"*",
"event_types",
")",
":",
"def",
"register",
"(",
"callback",
")",
":",
"types",
"=",
"[",
"MpvEventID",
".",
"from_str",
"(",
"t",
")",
"if",
"isinstance",
"(",
"t",
",",
"str",
")",
"else",
"t",
"for",... | Function decorator to register a blanket event callback for the given event types. Event types can be given
as str (e.g. 'start-file'), integer or MpvEventID object.
WARNING: Due to the way this is filtering events, this decorator cannot be chained with itself.
To unregister the event callbac... | [
"Function",
"decorator",
"to",
"register",
"a",
"blanket",
"event",
"callback",
"for",
"the",
"given",
"event",
"types",
".",
"Event",
"types",
"can",
"be",
"given",
"as",
"str",
"(",
"e",
".",
"g",
".",
"start",
"-",
"file",
")",
"integer",
"or",
"Mpv... | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L901-L925 |
jaseg/python-mpv | mpv.py | MPV.on_key_press | def on_key_press(self, keydef, mode='force'):
"""Function decorator to register a simplified key binding. The callback is called whenever the key given is
*pressed*.
To unregister the callback function, you can call its ``unregister_mpv_key_bindings`` attribute::
player = mpv.MPV()... | python | def on_key_press(self, keydef, mode='force'):
"""Function decorator to register a simplified key binding. The callback is called whenever the key given is
*pressed*.
To unregister the callback function, you can call its ``unregister_mpv_key_bindings`` attribute::
player = mpv.MPV()... | [
"def",
"on_key_press",
"(",
"self",
",",
"keydef",
",",
"mode",
"=",
"'force'",
")",
":",
"def",
"register",
"(",
"fun",
")",
":",
"@",
"self",
".",
"key_binding",
"(",
"keydef",
",",
"mode",
")",
"@",
"wraps",
"(",
"fun",
")",
"def",
"wrapper",
"(... | Function decorator to register a simplified key binding. The callback is called whenever the key given is
*pressed*.
To unregister the callback function, you can call its ``unregister_mpv_key_bindings`` attribute::
player = mpv.MPV()
@player.on_key_press('Q')
def bi... | [
"Function",
"decorator",
"to",
"register",
"a",
"simplified",
"key",
"binding",
".",
"The",
"callback",
"is",
"called",
"whenever",
"the",
"key",
"given",
"is",
"*",
"pressed",
"*",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L931-L957 |
jaseg/python-mpv | mpv.py | MPV.key_binding | def key_binding(self, keydef, mode='force'):
"""Function decorator to register a low-level key binding.
The callback function signature is ``fun(key_state, key_name)`` where ``key_state`` is either ``'U'`` for "key
up" or ``'D'`` for "key down".
The keydef format is: ``[Shift+][Ctrl+][... | python | def key_binding(self, keydef, mode='force'):
"""Function decorator to register a low-level key binding.
The callback function signature is ``fun(key_state, key_name)`` where ``key_state`` is either ``'U'`` for "key
up" or ``'D'`` for "key down".
The keydef format is: ``[Shift+][Ctrl+][... | [
"def",
"key_binding",
"(",
"self",
",",
"keydef",
",",
"mode",
"=",
"'force'",
")",
":",
"def",
"register",
"(",
"fun",
")",
":",
"fun",
".",
"mpv_key_bindings",
"=",
"getattr",
"(",
"fun",
",",
"'mpv_key_bindings'",
",",
"[",
"]",
")",
"+",
"[",
"ke... | Function decorator to register a low-level key binding.
The callback function signature is ``fun(key_state, key_name)`` where ``key_state`` is either ``'U'`` for "key
up" or ``'D'`` for "key down".
The keydef format is: ``[Shift+][Ctrl+][Alt+][Meta+]<key>`` where ``<key>`` is either the litera... | [
"Function",
"decorator",
"to",
"register",
"a",
"low",
"-",
"level",
"key",
"binding",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L959-L996 |
jaseg/python-mpv | mpv.py | MPV.register_key_binding | def register_key_binding(self, keydef, callback_or_cmd, mode='force'):
"""Register a key binding. This takes an mpv keydef and either a string containing a mpv command or a python
callback function. See ``MPV.key_binding`` for details.
"""
if not re.match(r'(Shift+)?(Ctrl+)?(Alt+)?(Meta... | python | def register_key_binding(self, keydef, callback_or_cmd, mode='force'):
"""Register a key binding. This takes an mpv keydef and either a string containing a mpv command or a python
callback function. See ``MPV.key_binding`` for details.
"""
if not re.match(r'(Shift+)?(Ctrl+)?(Alt+)?(Meta... | [
"def",
"register_key_binding",
"(",
"self",
",",
"keydef",
",",
"callback_or_cmd",
",",
"mode",
"=",
"'force'",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"r'(Shift+)?(Ctrl+)?(Alt+)?(Meta+)?(.|\\w+)'",
",",
"keydef",
")",
":",
"raise",
"ValueError",
"(",
... | Register a key binding. This takes an mpv keydef and either a string containing a mpv command or a python
callback function. See ``MPV.key_binding`` for details. | [
"Register",
"a",
"key",
"binding",
".",
"This",
"takes",
"an",
"mpv",
"keydef",
"and",
"either",
"a",
"string",
"containing",
"a",
"mpv",
"command",
"or",
"a",
"python",
"callback",
"function",
".",
"See",
"MPV",
".",
"key_binding",
"for",
"details",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L998-L1016 |
jaseg/python-mpv | mpv.py | MPV.unregister_key_binding | def unregister_key_binding(self, keydef):
"""Unregister a key binding by keydef."""
binding_name = MPV._binding_name(keydef)
self.command('disable-section', binding_name)
self.command('define-section', binding_name, '')
if binding_name in self._key_binding_handlers:
d... | python | def unregister_key_binding(self, keydef):
"""Unregister a key binding by keydef."""
binding_name = MPV._binding_name(keydef)
self.command('disable-section', binding_name)
self.command('define-section', binding_name, '')
if binding_name in self._key_binding_handlers:
d... | [
"def",
"unregister_key_binding",
"(",
"self",
",",
"keydef",
")",
":",
"binding_name",
"=",
"MPV",
".",
"_binding_name",
"(",
"keydef",
")",
"self",
".",
"command",
"(",
"'disable-section'",
",",
"binding_name",
")",
"self",
".",
"command",
"(",
"'define-secti... | Unregister a key binding by keydef. | [
"Unregister",
"a",
"key",
"binding",
"by",
"keydef",
"."
] | train | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L1021-L1029 |
lwcolton/falcon-cors | src/falcon_cors/__init__.py | CORS._process_origin | def _process_origin(self, req, resp, origin):
"""Inspects the request and adds the Access-Control-Allow-Origin
header if the requested origin is allowed.
Returns:
``True`` if the header was added and the requested origin
is allowed, ``False`` if the origin is not allowed... | python | def _process_origin(self, req, resp, origin):
"""Inspects the request and adds the Access-Control-Allow-Origin
header if the requested origin is allowed.
Returns:
``True`` if the header was added and the requested origin
is allowed, ``False`` if the origin is not allowed... | [
"def",
"_process_origin",
"(",
"self",
",",
"req",
",",
"resp",
",",
"origin",
")",
":",
"if",
"self",
".",
"_cors_config",
"[",
"'allow_all_origins'",
"]",
":",
"if",
"self",
".",
"supports_credentials",
":",
"self",
".",
"_set_allow_origin",
"(",
"resp",
... | Inspects the request and adds the Access-Control-Allow-Origin
header if the requested origin is allowed.
Returns:
``True`` if the header was added and the requested origin
is allowed, ``False`` if the origin is not allowed and the
header has not been added. | [
"Inspects",
"the",
"request",
"and",
"adds",
"the",
"Access",
"-",
"Control",
"-",
"Allow",
"-",
"Origin",
"header",
"if",
"the",
"requested",
"origin",
"is",
"allowed",
"."
] | train | https://github.com/lwcolton/falcon-cors/blob/9e1243829078e4c6f8fb8bb895b5cad62bce9d6b/src/falcon_cors/__init__.py#L303-L329 |
lwcolton/falcon-cors | src/falcon_cors/__init__.py | CORS._process_allow_headers | def _process_allow_headers(self, req, resp, requested_headers):
"""Adds the Access-Control-Allow-Headers header to the response,
using the cors settings to determine which headers are allowed.
Returns:
True if all the headers the client requested are allowed.
False if so... | python | def _process_allow_headers(self, req, resp, requested_headers):
"""Adds the Access-Control-Allow-Headers header to the response,
using the cors settings to determine which headers are allowed.
Returns:
True if all the headers the client requested are allowed.
False if so... | [
"def",
"_process_allow_headers",
"(",
"self",
",",
"req",
",",
"resp",
",",
"requested_headers",
")",
":",
"if",
"not",
"requested_headers",
":",
"return",
"True",
"elif",
"self",
".",
"_cors_config",
"[",
"'allow_all_headers'",
"]",
":",
"self",
".",
"_set_al... | Adds the Access-Control-Allow-Headers header to the response,
using the cors settings to determine which headers are allowed.
Returns:
True if all the headers the client requested are allowed.
False if some or none of the headers the client requested are allowed. | [
"Adds",
"the",
"Access",
"-",
"Control",
"-",
"Allow",
"-",
"Headers",
"header",
"to",
"the",
"response",
"using",
"the",
"cors",
"settings",
"to",
"determine",
"which",
"headers",
"are",
"allowed",
"."
] | train | https://github.com/lwcolton/falcon-cors/blob/9e1243829078e4c6f8fb8bb895b5cad62bce9d6b/src/falcon_cors/__init__.py#L331-L357 |
lwcolton/falcon-cors | src/falcon_cors/__init__.py | CORS._process_methods | def _process_methods(self, req, resp, resource):
"""Adds the Access-Control-Allow-Methods header to the response,
using the cors settings to determine which methods are allowed.
"""
requested_method = self._get_requested_method(req)
if not requested_method:
return Fal... | python | def _process_methods(self, req, resp, resource):
"""Adds the Access-Control-Allow-Methods header to the response,
using the cors settings to determine which methods are allowed.
"""
requested_method = self._get_requested_method(req)
if not requested_method:
return Fal... | [
"def",
"_process_methods",
"(",
"self",
",",
"req",
",",
"resp",
",",
"resource",
")",
":",
"requested_method",
"=",
"self",
".",
"_get_requested_method",
"(",
"req",
")",
"if",
"not",
"requested_method",
":",
"return",
"False",
"if",
"self",
".",
"_cors_con... | Adds the Access-Control-Allow-Methods header to the response,
using the cors settings to determine which methods are allowed. | [
"Adds",
"the",
"Access",
"-",
"Control",
"-",
"Allow",
"-",
"Methods",
"header",
"to",
"the",
"response",
"using",
"the",
"cors",
"settings",
"to",
"determine",
"which",
"methods",
"are",
"allowed",
"."
] | train | https://github.com/lwcolton/falcon-cors/blob/9e1243829078e4c6f8fb8bb895b5cad62bce9d6b/src/falcon_cors/__init__.py#L359-L384 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.