Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
PlenticoreDataFormatter.format_inverter_state | (state: str) | Return a readable string of the inverter state. | Return a readable string of the inverter state. | def format_inverter_state(state: str) -> str:
"""Return a readable string of the inverter state."""
try:
value = int(state)
except (TypeError, ValueError):
return state
return PlenticoreDataFormatter.INVERTER_STATES.get(value) | [
"def",
"format_inverter_state",
"(",
"state",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"value",
"=",
"int",
"(",
"state",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"state",
"return",
"PlenticoreDataFormatter",
".",
"INVE... | [
242,
4
] | [
249,
65
] | python | en | ['en', 'en', 'en'] | True |
PlenticoreDataFormatter.format_em_manager_state | (state: str) | Return a readable state of the energy manager. | Return a readable state of the energy manager. | def format_em_manager_state(state: str) -> str:
"""Return a readable state of the energy manager."""
try:
value = int(state)
except (TypeError, ValueError):
return state
return PlenticoreDataFormatter.EM_STATES.get(value) | [
"def",
"format_em_manager_state",
"(",
"state",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"value",
"=",
"int",
"(",
"state",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"state",
"return",
"PlenticoreDataFormatter",
".",
"EM... | [
252,
4
] | [
259,
59
] | python | en | ['en', 'en', 'en'] | True |
PGroupFlangCompiler.get_library_dirs | (self) | List of compiler library directories. | List of compiler library directories. | def get_library_dirs(self):
"""List of compiler library directories."""
opt = FCompiler.get_library_dirs(self)
flang_dir = dirname(self.executables['compiler_f77'][0])
opt.append(normpath(join(flang_dir, '..', 'lib')))
return opt | [
"def",
"get_library_dirs",
"(",
"self",
")",
":",
"opt",
"=",
"FCompiler",
".",
"get_library_dirs",
"(",
"self",
")",
"flang_dir",
"=",
"dirname",
"(",
"self",
".",
"executables",
"[",
"'compiler_f77'",
"]",
"[",
"0",
"]",
")",
"opt",
".",
"append",
"(",... | [
93,
4
] | [
99,
18
] | python | en | ['en', 'en', 'en'] | True |
test_cannot_connect | (hass) | Test connection error. | Test connection error. | async def test_cannot_connect(hass):
"""Test connection error."""
with patch(
"homeassistant.components.risco.RiscoAPI.login",
side_effect=CannotConnectError,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG)
config_entry.add_to_hass(hass)
await hass... | [
"async",
"def",
"test_cannot_connect",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.risco.RiscoAPI.login\"",
",",
"side_effect",
"=",
"CannotConnectError",
",",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",... | [
111,
0
] | [
125,
51
] | python | de | ['eu', 'de', 'en'] | False |
test_unauthorized | (hass) | Test unauthorized error. | Test unauthorized error. | async def test_unauthorized(hass):
"""Test unauthorized error."""
with patch(
"homeassistant.components.risco.RiscoAPI.login",
side_effect=UnauthorizedError,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG)
config_entry.add_to_hass(hass)
await hass.... | [
"async",
"def",
"test_unauthorized",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.risco.RiscoAPI.login\"",
",",
"side_effect",
"=",
"UnauthorizedError",
",",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
... | [
128,
0
] | [
142,
51
] | python | ca | ['ca', 'de', 'it'] | False |
test_setup | (hass, two_zone_alarm) | Test entity setup. | Test entity setup. | async def test_setup(hass, two_zone_alarm): # noqa: F811
"""Test entity setup."""
registry = er.async_get(hass)
for id in ENTITY_IDS.values():
assert not registry.async_is_registered(id)
with patch(
"homeassistant.components.risco.RiscoAPI.site_uuid",
new_callable=PropertyMock... | [
"async",
"def",
"test_setup",
"(",
"hass",
",",
"two_zone_alarm",
")",
":",
"# noqa: F811",
"registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"for",
"id",
"in",
"ENTITY_IDS",
".",
"values",
"(",
")",
":",
"assert",
"not",
"registry",
".",
"async... | [
168,
0
] | [
202,
47
] | python | en | ['en', 'zu', 'en'] | True |
test_switch_state | (
hass: HomeAssistant, init_integration: MockConfigEntry
) | Test the creation and values of the WLED switches. | Test the creation and values of the WLED switches. | async def test_switch_state(
hass: HomeAssistant, init_integration: MockConfigEntry
) -> None:
"""Test the creation and values of the WLED switches."""
entity_registry = er.async_get(hass)
state = hass.states.get("switch.wled_rgb_light_nightlight")
assert state
assert state.attributes.get(ATTR_... | [
"async",
"def",
"test_switch_state",
"(",
"hass",
":",
"HomeAssistant",
",",
"init_integration",
":",
"MockConfigEntry",
")",
"->",
"None",
":",
"entity_registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get"... | [
28,
0
] | [
64,
57
] | python | en | ['en', 'en', 'en'] | True |
test_switch_change_state | (
hass: HomeAssistant, init_integration: MockConfigEntry, mock_wled: MagicMock
) | Test the change of state of the WLED switches. | Test the change of state of the WLED switches. | async def test_switch_change_state(
hass: HomeAssistant, init_integration: MockConfigEntry, mock_wled: MagicMock
) -> None:
"""Test the change of state of the WLED switches."""
# Nightlight
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "switch.... | [
"async",
"def",
"test_switch_change_state",
"(",
"hass",
":",
"HomeAssistant",
",",
"init_integration",
":",
"MockConfigEntry",
",",
"mock_wled",
":",
"MagicMock",
")",
"->",
"None",
":",
"# Nightlight",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
... | [
67,
0
] | [
133,
51
] | python | en | ['en', 'en', 'en'] | True |
test_switch_error | (
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
caplog: pytest.LogCaptureFixture,
) | Test error handling of the WLED switches. | Test error handling of the WLED switches. | async def test_switch_error(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test error handling of the WLED switches."""
mock_wled.nightlight.side_effect = WLEDError
await hass.services.async_call(
SWITCH... | [
"async",
"def",
"test_switch_error",
"(",
"hass",
":",
"HomeAssistant",
",",
"init_integration",
":",
"MockConfigEntry",
",",
"mock_wled",
":",
"MagicMock",
",",
"caplog",
":",
"pytest",
".",
"LogCaptureFixture",
",",
")",
"->",
"None",
":",
"mock_wled",
".",
... | [
136,
0
] | [
156,
53
] | python | en | ['en', 'en', 'en'] | True |
test_switch_connection_error | (
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
caplog: pytest.LogCaptureFixture,
) | Test error handling of the WLED switches. | Test error handling of the WLED switches. | async def test_switch_connection_error(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test error handling of the WLED switches."""
mock_wled.nightlight.side_effect = WLEDConnectionError
await hass.services.async... | [
"async",
"def",
"test_switch_connection_error",
"(",
"hass",
":",
"HomeAssistant",
",",
"init_integration",
":",
"MockConfigEntry",
",",
"mock_wled",
":",
"MagicMock",
",",
"caplog",
":",
"pytest",
".",
"LogCaptureFixture",
",",
")",
"->",
"None",
":",
"mock_wled"... | [
159,
0
] | [
179,
56
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Tube sensor. | Set up the Tube sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tube sensor."""
data = TubeData()
data.update()
sensors = []
for line in config.get(CONF_LINE):
sensors.append(LondonTubeSensor(line, data))
add_entities(sensors, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"data",
"=",
"TubeData",
"(",
")",
"data",
".",
"update",
"(",
")",
"sensors",
"=",
"[",
"]",
"for",
"line",
"in",
"config",
".",
... | [
40,
0
] | [
49,
31
] | python | en | ['en', 'sq', 'en'] | True |
LondonTubeSensor.__init__ | (self, name, data) | Initialize the London Underground sensor. | Initialize the London Underground sensor. | def __init__(self, name, data):
"""Initialize the London Underground sensor."""
self._data = data
self._description = None
self._name = name
self._state = None
self.attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_description",
"=",
"None",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"attrs",
"=",
"{",
... | [
55,
4
] | [
61,
52
] | python | en | ['en', 'zu', 'en'] | True |
LondonTubeSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
64,
4
] | [
66,
25
] | python | en | ['en', 'mi', 'en'] | True |
LondonTubeSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
69,
4
] | [
71,
26
] | python | en | ['en', 'en', 'en'] | True |
LondonTubeSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
74,
4
] | [
76,
19
] | python | en | ['en', 'en', 'en'] | True |
LondonTubeSensor.extra_state_attributes | (self) | Return other details about the sensor state. | Return other details about the sensor state. | def extra_state_attributes(self):
"""Return other details about the sensor state."""
self.attrs["Description"] = self._description
return self.attrs | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"self",
".",
"attrs",
"[",
"\"Description\"",
"]",
"=",
"self",
".",
"_description",
"return",
"self",
".",
"attrs"
] | [
79,
4
] | [
82,
25
] | python | en | ['en', 'en', 'en'] | True |
LondonTubeSensor.update | (self) | Update the sensor. | Update the sensor. | def update(self):
"""Update the sensor."""
self._data.update()
self._state = self._data.data[self.name]["State"]
self._description = self._data.data[self.name]["Description"] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_data",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_data",
".",
"data",
"[",
"self",
".",
"name",
"]",
"[",
"\"State\"",
"]",
"self",
".",
"_description",
"=",
"self",
... | [
84,
4
] | [
88,
69
] | python | en | ['en', 'nl', 'en'] | True |
GetEmail | (prompt) | Prompts the user for their email address and returns it.
The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
for next time we prompt.
... | Prompts the user for their email address and returns it. | def GetEmail(prompt):
"""Prompts the user for their email address and returns it.
The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
... | [
"def",
"GetEmail",
"(",
"prompt",
")",
":",
"last_email_file_name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.last_codereview_email_address\"",
")",
"last_email",
"=",
"\"\"",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"last_email_file_name",
")",
... | [
79,
0
] | [
108,
14
] | python | en | ['en', 'en', 'en'] | True |
StatusUpdate | (msg) | Print a status message to stdout.
If 'verbosity' is greater than 0, print the message.
Args:
msg: The string to print.
| Print a status message to stdout. | def StatusUpdate(msg):
"""Print a status message to stdout.
If 'verbosity' is greater than 0, print the message.
Args:
msg: The string to print.
"""
if verbosity > 0:
print msg | [
"def",
"StatusUpdate",
"(",
"msg",
")",
":",
"if",
"verbosity",
">",
"0",
":",
"print",
"msg"
] | [
111,
0
] | [
120,
13
] | python | en | ['en', 'en', 'en'] | True |
ErrorExit | (msg) | Print an error message to stderr and exit. | Print an error message to stderr and exit. | def ErrorExit(msg):
"""Print an error message to stderr and exit."""
print >>sys.stderr, msg
sys.exit(1) | [
"def",
"ErrorExit",
"(",
"msg",
")",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"msg",
"sys",
".",
"exit",
"(",
"1",
")"
] | [
123,
0
] | [
126,
13
] | python | en | ['en', 'en', 'en'] | True |
GetRpcServer | (options) | Returns an instance of an AbstractRpcServer.
Returns:
A new AbstractRpcServer, on which RPC calls can be made.
| Returns an instance of an AbstractRpcServer. | def GetRpcServer(options):
"""Returns an instance of an AbstractRpcServer.
Returns:
A new AbstractRpcServer, on which RPC calls can be made.
"""
rpc_server_class = HttpRpcServer
def GetUserCredentials():
"""Prompts the user for a username and password."""
email = options.email
if email is N... | [
"def",
"GetRpcServer",
"(",
"options",
")",
":",
"rpc_server_class",
"=",
"HttpRpcServer",
"def",
"GetUserCredentials",
"(",
")",
":",
"\"\"\"Prompts the user for a username and password.\"\"\"",
"email",
"=",
"options",
".",
"email",
"if",
"email",
"is",
"None",
":",... | [
472,
0
] | [
509,
60
] | python | en | ['en', 'en', 'en'] | True |
EncodeMultipartFormData | (fields, files) | Encode form fields for multipart/form-data.
Args:
fields: A sequence of (name, value) elements for regular form fields.
files: A sequence of (name, filename, value) elements for data to be
uploaded as files.
Returns:
(content_type, body) ready for httplib.HTTP instance.
Source:
https:... | Encode form fields for multipart/form-data. | def EncodeMultipartFormData(fields, files):
"""Encode form fields for multipart/form-data.
Args:
fields: A sequence of (name, value) elements for regular form fields.
files: A sequence of (name, filename, value) elements for data to be
uploaded as files.
Returns:
(content_type, body) ready... | [
"def",
"EncodeMultipartFormData",
"(",
"fields",
",",
"files",
")",
":",
"BOUNDARY",
"=",
"'-M-A-G-I-C---B-O-U-N-D-A-R-Y-'",
"CRLF",
"=",
"'\\r\\n'",
"lines",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"fields",
":",
"lines",
".",
"append",
... | [
512,
0
] | [
544,
27
] | python | en | ['en', 'en', 'en'] | True |
GetContentType | (filename) | Helper to guess the content-type from the filename. | Helper to guess the content-type from the filename. | def GetContentType(filename):
"""Helper to guess the content-type from the filename."""
return mimetypes.guess_type(filename)[0] or 'application/octet-stream' | [
"def",
"GetContentType",
"(",
"filename",
")",
":",
"return",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"or",
"'application/octet-stream'"
] | [
547,
0
] | [
549,
72
] | python | en | ['en', 'en', 'en'] | True |
RunShellWithReturnCode | (command, print_output=False,
universal_newlines=True) | Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, both stdout and stderr are ignored.
universal_newlines: Use universal_newlines flag (default: True).
Returns... | Executes a command and returns the output from stdout and the return code. | def RunShellWithReturnCode(command, print_output=False,
universal_newlines=True):
"""Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, b... | [
"def",
"RunShellWithReturnCode",
"(",
"command",
",",
"print_output",
"=",
"False",
",",
"universal_newlines",
"=",
"True",
")",
":",
"logging",
".",
"info",
"(",
"\"Running %s\"",
",",
"command",
")",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",... | [
555,
0
] | [
588,
29
] | python | en | ['en', 'en', 'en'] | True |
SplitPatch | (data) | Splits a patch into separate pieces for each file.
Args:
data: A string containing the output of svn diff.
Returns:
A list of 2-tuple (filename, text) where text is the svn diff output
pertaining to filename.
| Splits a patch into separate pieces for each file. | def SplitPatch(data):
"""Splits a patch into separate pieces for each file.
Args:
data: A string containing the output of svn diff.
Returns:
A list of 2-tuple (filename, text) where text is the svn diff output
pertaining to filename.
"""
patches = []
filename = None
diff = []
for line in... | [
"def",
"SplitPatch",
"(",
"data",
")",
":",
"patches",
"=",
"[",
"]",
"filename",
"=",
"None",
"diff",
"=",
"[",
"]",
"for",
"line",
"in",
"data",
".",
"splitlines",
"(",
"True",
")",
":",
"new_filename",
"=",
"None",
"if",
"line",
".",
"startswith",... | [
1155,
0
] | [
1192,
16
] | python | en | ['en', 'en', 'en'] | True |
UploadSeparatePatches | (issue, rpc_server, patchset, data, options) | Uploads a separate patch for each file in the diff output.
Returns a list of [patch_key, filename] for each file.
| Uploads a separate patch for each file in the diff output. | def UploadSeparatePatches(issue, rpc_server, patchset, data, options):
"""Uploads a separate patch for each file in the diff output.
Returns a list of [patch_key, filename] for each file.
"""
patches = SplitPatch(data)
rv = []
for patch in patches:
if len(patch[1]) > MAX_UPLOAD_SIZE:
print ("Not ... | [
"def",
"UploadSeparatePatches",
"(",
"issue",
",",
"rpc_server",
",",
"patchset",
",",
"data",
",",
"options",
")",
":",
"patches",
"=",
"SplitPatch",
"(",
"data",
")",
"rv",
"=",
"[",
"]",
"for",
"patch",
"in",
"patches",
":",
"if",
"len",
"(",
"patch... | [
1195,
0
] | [
1220,
11
] | python | en | ['en', 'en', 'en'] | True |
GuessVCS | (options) | Helper to guess the version control system.
This examines the current directory, guesses which VersionControlSystem
we're using, and returns an instance of the appropriate class. Exit with an
error if we can't figure it out.
Returns:
A VersionControlSystem instance. Exits if the VCS can't be guessed.
| Helper to guess the version control system. | def GuessVCS(options):
"""Helper to guess the version control system.
This examines the current directory, guesses which VersionControlSystem
we're using, and returns an instance of the appropriate class. Exit with an
error if we can't figure it out.
Returns:
A VersionControlSystem instance. Exits if t... | [
"def",
"GuessVCS",
"(",
"options",
")",
":",
"# Mercurial has a command to get the base directory of a repository",
"# Try running it, but don't die if we don't have hg installed.",
"# NOTE: we try Mercurial first as it can sit on top of an SVN working copy.",
"try",
":",
"out",
",",
"retu... | [
1223,
0
] | [
1261,
53
] | python | en | ['en', 'en', 'en'] | True |
RealMain | (argv, data=None) | The real main function.
Args:
argv: Command line arguments.
data: Diff contents. If None (default) the diff is generated by
the VersionControlSystem implementation returned by GuessVCS().
Returns:
A 2-tuple (issue id, patchset id).
The patchset id is None if the base files are not uploaded b... | The real main function. | def RealMain(argv, data=None):
"""The real main function.
Args:
argv: Command line arguments.
data: Diff contents. If None (default) the diff is generated by
the VersionControlSystem implementation returned by GuessVCS().
Returns:
A 2-tuple (issue id, patchset id).
The patchset id is None ... | [
"def",
"RealMain",
"(",
"argv",
",",
"data",
"=",
"None",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"(",
"\"%(asctime).19s %(levelname)s %(filename)s:\"",
"\"%(lineno)s %(message)s \"",
")",
")",
"os",
".",
"environ",
"[",
"'LC_ALL'",
"]",
"="... | [
1264,
0
] | [
1388,
24
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer.__init__ | (self, host, auth_function, host_override=None, extra_headers={},
save_cookies=False) | Creates a new HttpRpcServer.
Args:
host: The host to send requests to.
auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
host_override: The host header to send to the server (defaults... | Creates a new HttpRpcServer. | def __init__(self, host, auth_function, host_override=None, extra_headers={},
save_cookies=False):
"""Creates a new HttpRpcServer.
Args:
host: The host to send requests to.
auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. W... | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"auth_function",
",",
"host_override",
"=",
"None",
",",
"extra_headers",
"=",
"{",
"}",
",",
"save_cookies",
"=",
"False",
")",
":",
"self",
".",
"host",
"=",
"host",
"self",
".",
"host_override",
"=",
... | [
141,
2
] | [
166,
43
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer._GetOpener | (self) | Returns an OpenerDirector for making HTTP requests.
Returns:
A urllib2.OpenerDirector object.
| Returns an OpenerDirector for making HTTP requests. | def _GetOpener(self):
"""Returns an OpenerDirector for making HTTP requests.
Returns:
A urllib2.OpenerDirector object.
"""
raise NotImplementedError() | [
"def",
"_GetOpener",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
168,
2
] | [
174,
31
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer._CreateRequest | (self, url, data=None) | Creates a new urllib request. | Creates a new urllib request. | def _CreateRequest(self, url, data=None):
"""Creates a new urllib request."""
logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
req = urllib2.Request(url, data=data)
if self.host_override:
req.add_header("Host", self.host_override)
for key, value in self.extra_headers.it... | [
"def",
"_CreateRequest",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\"Creating request for: '%s' with payload:\\n%s\"",
",",
"url",
",",
"data",
")",
"req",
"=",
"urllib2",
".",
"Request",
"(",
"url",
",",
"... | [
176,
2
] | [
184,
14
] | python | en | ['en', 'mt', 'en'] | True |
AbstractRpcServer._GetAuthToken | (self, email, password) | Uses ClientLogin to authenticate the user, returning an auth token.
Args:
email: The user's email address
password: The user's password
Raises:
ClientLoginError: If there was an error authenticating with ClientLogin.
HTTPError: If there was some other form of HTTP error.
Return... | Uses ClientLogin to authenticate the user, returning an auth token. | def _GetAuthToken(self, email, password):
"""Uses ClientLogin to authenticate the user, returning an auth token.
Args:
email: The user's email address
password: The user's password
Raises:
ClientLoginError: If there was an error authenticating with ClientLogin.
HTTPError: If the... | [
"def",
"_GetAuthToken",
"(",
"self",
",",
"email",
",",
"password",
")",
":",
"account_type",
"=",
"\"GOOGLE\"",
"if",
"self",
".",
"host",
".",
"endswith",
"(",
"\".google.com\"",
")",
":",
"# Needed for use inside Google.",
"account_type",
"=",
"\"HOSTED\"",
"... | [
186,
2
] | [
227,
13
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer._GetAuthCookie | (self, auth_token) | Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication cookies.
| Fetches authentication cookies for an authentication token. | def _GetAuthCookie(self, auth_token):
"""Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication cookies.
"""
# This is a dummy value to allow us... | [
"def",
"_GetAuthCookie",
"(",
"self",
",",
"auth_token",
")",
":",
"# This is a dummy value to allow us to identify when we're successful.",
"continue_location",
"=",
"\"http://localhost/\"",
"args",
"=",
"{",
"\"continue\"",
":",
"continue_location",
",",
"\"auth\"",
":",
... | [
229,
2
] | [
251,
29
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer._Authenticate | (self) | Authenticates the user.
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see https://developers.google.com/identity/protocols/AuthForInstalledApps).
3) We pass the auth token to /_ah/login... | Authenticates the user. | def _Authenticate(self):
"""Authenticates the user.
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see https://developers.google.com/identity/protocols/AuthForInstalledApps).
3) We p... | [
"def",
"_Authenticate",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"credentials",
"=",
"self",
".",
"auth_function",
"(",
")",
"try",
":",
"auth_token",
"=",
"self",
".",
"_GetAuthToken",
"(",
"credentials",
"[",
"0",
"]",
... | [
253,
2
] | [
303,
12
] | python | en | ['en', 'en', 'en'] | True |
AbstractRpcServer.Send | (self, request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
**kwargs) | Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an empty request.
content_type: The Content-Type header to use.
timeout: timeout in seconds; default None i.e. no timeout.... | Sends an RPC and returns the response. | def Send(self, request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
**kwargs):
"""Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, o... | [
"def",
"Send",
"(",
"self",
",",
"request_path",
",",
"payload",
"=",
"None",
",",
"content_type",
"=",
"\"application/octet-stream\"",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Don't require authentication. Let the server say",
"# wh... | [
305,
2
] | [
355,
43
] | python | en | ['en', 'en', 'en'] | True |
HttpRpcServer._Authenticate | (self) | Save the cookie jar after authentication. | Save the cookie jar after authentication. | def _Authenticate(self):
"""Save the cookie jar after authentication."""
super(HttpRpcServer, self)._Authenticate()
if self.save_cookies:
StatusUpdate("Saving authentication cookies to %s" % self.cookie_file)
self.cookie_jar.save() | [
"def",
"_Authenticate",
"(",
"self",
")",
":",
"super",
"(",
"HttpRpcServer",
",",
"self",
")",
".",
"_Authenticate",
"(",
")",
"if",
"self",
".",
"save_cookies",
":",
"StatusUpdate",
"(",
"\"Saving authentication cookies to %s\"",
"%",
"self",
".",
"cookie_file... | [
361,
2
] | [
366,
28
] | python | en | ['en', 'en', 'en'] | True |
HttpRpcServer._GetOpener | (self) | Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object.
| Returns an OpenerDirector that supports cookies and ignores redirects. | def _GetOpener(self):
"""Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object.
"""
opener = urllib2.OpenerDirector()
opener.add_handler(urllib2.ProxyHandler())
opener.add_handler(urllib2.UnknownHandler())
opener.add_handler(ur... | [
"def",
"_GetOpener",
"(",
"self",
")",
":",
"opener",
"=",
"urllib2",
".",
"OpenerDirector",
"(",
")",
"opener",
".",
"add_handler",
"(",
"urllib2",
".",
"ProxyHandler",
"(",
")",
")",
"opener",
".",
"add_handler",
"(",
"urllib2",
".",
"UnknownHandler",
"(... | [
368,
2
] | [
403,
17
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.__init__ | (self, options) | Constructor.
Args:
options: Command line options.
| Constructor. | def __init__(self, options):
"""Constructor.
Args:
options: Command line options.
"""
self.options = options | [
"def",
"__init__",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"options",
"=",
"options"
] | [
605,
2
] | [
611,
26
] | python | en | ['en', 'en', 'en'] | False |
VersionControlSystem.GenerateDiff | (self, args) | Return the current diff as a string.
Args:
args: Extra arguments to pass to the diff command.
| Return the current diff as a string. | def GenerateDiff(self, args):
"""Return the current diff as a string.
Args:
args: Extra arguments to pass to the diff command.
"""
raise NotImplementedError(
"abstract method -- subclass %s must override" % self.__class__) | [
"def",
"GenerateDiff",
"(",
"self",
",",
"args",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"abstract method -- subclass %s must override\"",
"%",
"self",
".",
"__class__",
")"
] | [
613,
2
] | [
620,
72
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.GetUnknownFiles | (self) | Return a list of files unknown to the VCS. | Return a list of files unknown to the VCS. | def GetUnknownFiles(self):
"""Return a list of files unknown to the VCS."""
raise NotImplementedError(
"abstract method -- subclass %s must override" % self.__class__) | [
"def",
"GetUnknownFiles",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"abstract method -- subclass %s must override\"",
"%",
"self",
".",
"__class__",
")"
] | [
622,
2
] | [
625,
72
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.CheckForUnknownFiles | (self) | Show an "are you sure?" prompt if there are unknown files. | Show an "are you sure?" prompt if there are unknown files. | def CheckForUnknownFiles(self):
"""Show an "are you sure?" prompt if there are unknown files."""
unknown_files = self.GetUnknownFiles()
if unknown_files:
print "The following files are not added to version control:"
for line in unknown_files:
print line
prompt = "Are you sure to co... | [
"def",
"CheckForUnknownFiles",
"(",
"self",
")",
":",
"unknown_files",
"=",
"self",
".",
"GetUnknownFiles",
"(",
")",
"if",
"unknown_files",
":",
"print",
"\"The following files are not added to version control:\"",
"for",
"line",
"in",
"unknown_files",
":",
"print",
... | [
627,
2
] | [
637,
33
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.GetBaseFile | (self, filename) | Get the content of the upstream version of a file.
Returns:
A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty. For binary files, this is
the contents of the new file, since the diff output ... | Get the content of the upstream version of a file. | def GetBaseFile(self, filename):
"""Get the content of the upstream version of a file.
Returns:
A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty. For binary files, this is
the contents... | [
"def",
"GetBaseFile",
"(",
"self",
",",
"filename",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"abstract method -- subclass %s must override\"",
"%",
"self",
".",
"__class__",
")"
] | [
639,
2
] | [
653,
72
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.GetBaseFiles | (self, diff) | Helper that calls GetBase file for each file in the patch.
Returns:
A dictionary that maps from filename to GetBaseFile's tuple. Filenames
are retrieved based on lines that start with "Index:" or
"Property changes on:".
| Helper that calls GetBase file for each file in the patch. | def GetBaseFiles(self, diff):
"""Helper that calls GetBase file for each file in the patch.
Returns:
A dictionary that maps from filename to GetBaseFile's tuple. Filenames
are retrieved based on lines that start with "Index:" or
"Property changes on:".
"""
files = {}
for line in ... | [
"def",
"GetBaseFiles",
"(",
"self",
",",
"diff",
")",
":",
"files",
"=",
"{",
"}",
"for",
"line",
"in",
"diff",
".",
"splitlines",
"(",
"True",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"'Index:'",
")",
"or",
"line",
".",
"startswith",
"(",
"... | [
656,
2
] | [
672,
16
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.UploadBaseFiles | (self, issue, rpc_server, patch_list, patchset, options,
files) | Uploads the base files (and if necessary, the current ones as well). | Uploads the base files (and if necessary, the current ones as well). | def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,
files):
"""Uploads the base files (and if necessary, the current ones as well)."""
def UploadFile(filename, file_id, content, is_binary, status, is_base):
"""Uploads a file to the server."""
file_too_l... | [
"def",
"UploadBaseFiles",
"(",
"self",
",",
"issue",
",",
"rpc_server",
",",
"patch_list",
",",
"patchset",
",",
"options",
",",
"files",
")",
":",
"def",
"UploadFile",
"(",
"filename",
",",
"file_id",
",",
"content",
",",
"is_binary",
",",
"status",
",",
... | [
675,
2
] | [
725,
76
] | python | en | ['en', 'en', 'en'] | True |
VersionControlSystem.IsImage | (self, filename) | Returns true if the filename has an image extension. | Returns true if the filename has an image extension. | def IsImage(self, filename):
"""Returns true if the filename has an image extension."""
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
return False
return mimetype.startswith("image/") | [
"def",
"IsImage",
"(",
"self",
",",
"filename",
")",
":",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"if",
"not",
"mimetype",
":",
"return",
"False",
"return",
"mimetype",
".",
"startswith",
"(",
"\"image/\"",
"... | [
727,
2
] | [
732,
40
] | python | en | ['en', 'en', 'en'] | True |
SubversionVCS.GuessBase | (self, required) | Wrapper for _GuessBase. | Wrapper for _GuessBase. | def GuessBase(self, required):
"""Wrapper for _GuessBase."""
return self.svn_base | [
"def",
"GuessBase",
"(",
"self",
",",
"required",
")",
":",
"return",
"self",
".",
"svn_base"
] | [
756,
2
] | [
758,
24
] | python | en | ['da', 'en', 'en'] | True |
SubversionVCS._GuessBase | (self, required) | Returns the SVN base URL.
Args:
required: If true, exits if the url can't be guessed, otherwise None is
returned.
| Returns the SVN base URL. | def _GuessBase(self, required):
"""Returns the SVN base URL.
Args:
required: If true, exits if the url can't be guessed, otherwise None is
returned.
"""
info = RunShell(["svn", "info"])
for line in info.splitlines():
words = line.split()
if len(words) == 2 and words[0] == ... | [
"def",
"_GuessBase",
"(",
"self",
",",
"required",
")",
":",
"info",
"=",
"RunShell",
"(",
"[",
"\"svn\"",
",",
"\"info\"",
"]",
")",
"for",
"line",
"in",
"info",
".",
"splitlines",
"(",
")",
":",
"words",
"=",
"line",
".",
"split",
"(",
")",
"if",... | [
760,
2
] | [
802,
15
] | python | en | ['en', 'no', 'en'] | True |
SubversionVCS._CollapseKeywords | (self, content, keyword_str) | Collapses SVN keywords. | Collapses SVN keywords. | def _CollapseKeywords(self, content, keyword_str):
"""Collapses SVN keywords."""
# svn cat translates keywords but svn diff doesn't. As a result of this
# behavior patching.PatchChunks() fails with a chunk mismatch error.
# This part was originally written by the Review Board development team
# who ... | [
"def",
"_CollapseKeywords",
"(",
"self",
",",
"content",
",",
"keyword_str",
")",
":",
"# svn cat translates keywords but svn diff doesn't. As a result of this",
"# behavior patching.PatchChunks() fails with a chunk mismatch error.",
"# This part was originally written by the Review Board de... | [
819,
2
] | [
848,
79
] | python | en | ['en', 'en', 'en'] | True |
SubversionVCS.ReadFile | (self, filename) | Returns the contents of a file. | Returns the contents of a file. | def ReadFile(self, filename):
"""Returns the contents of a file."""
file = open(filename, 'rb')
result = ""
try:
result = file.read()
finally:
file.close()
return result | [
"def",
"ReadFile",
"(",
"self",
",",
"filename",
")",
":",
"file",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"result",
"=",
"\"\"",
"try",
":",
"result",
"=",
"file",
".",
"read",
"(",
")",
"finally",
":",
"file",
".",
"close",
"(",
")",
"r... | [
858,
2
] | [
866,
17
] | python | en | ['en', 'en', 'en'] | True |
SubversionVCS.GetStatus | (self, filename) | Returns the status of a file. | Returns the status of a file. | def GetStatus(self, filename):
"""Returns the status of a file."""
if not self.options.revision:
status = RunShell(["svn", "status", "--ignore-externals", filename])
if not status:
ErrorExit("svn status returned no output for %s" % filename)
status_lines = status.splitlines()
# I... | [
"def",
"GetStatus",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"self",
".",
"options",
".",
"revision",
":",
"status",
"=",
"RunShell",
"(",
"[",
"\"svn\"",
",",
"\"status\"",
",",
"\"--ignore-externals\"",
",",
"filename",
"]",
")",
"if",
"not... | [
868,
2
] | [
910,
17
] | python | en | ['en', 'en', 'en'] | True |
MercurialVCS._GetRelPath | (self, filename) | Get relative path of a file according to the current directory,
given its logical path in the repo. | Get relative path of a file according to the current directory,
given its logical path in the repo. | def _GetRelPath(self, filename):
"""Get relative path of a file according to the current directory,
given its logical path in the repo."""
assert filename.startswith(self.subdir), filename
return filename[len(self.subdir):].lstrip(r"\/") | [
"def",
"_GetRelPath",
"(",
"self",
",",
"filename",
")",
":",
"assert",
"filename",
".",
"startswith",
"(",
"self",
".",
"subdir",
")",
",",
"filename",
"return",
"filename",
"[",
"len",
"(",
"self",
".",
"subdir",
")",
":",
"]",
".",
"lstrip",
"(",
... | [
1072,
2
] | [
1076,
52
] | python | en | ['en', 'en', 'en'] | True |
MercurialVCS.GetUnknownFiles | (self) | Return a list of files unknown to the VCS. | Return a list of files unknown to the VCS. | def GetUnknownFiles(self):
"""Return a list of files unknown to the VCS."""
args = []
status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."],
silent_ok=True)
unknown_files = []
for line in status.splitlines():
st, fn = line.split(" ", 1)
if st == "?":
unkno... | [
"def",
"GetUnknownFiles",
"(",
"self",
")",
":",
"args",
"=",
"[",
"]",
"status",
"=",
"RunShell",
"(",
"[",
"\"hg\"",
",",
"\"status\"",
",",
"\"--rev\"",
",",
"self",
".",
"base_rev",
",",
"\"-u\"",
",",
"\".\"",
"]",
",",
"silent_ok",
"=",
"True",
... | [
1104,
2
] | [
1114,
24
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_substitute_old_class | (mock_get_logger) | Test deprecated class object. | Test deprecated class object. | def test_deprecated_substitute_old_class(mock_get_logger):
"""Test deprecated class object."""
mock_logger = MagicMock()
mock_get_logger.return_value = mock_logger
mock_object = MockDeprecatedClass()
assert mock_object.new_property is True
assert mock_object.new_property is True
assert mock... | [
"def",
"test_deprecated_substitute_old_class",
"(",
"mock_get_logger",
")",
":",
"mock_logger",
"=",
"MagicMock",
"(",
")",
"mock_get_logger",
".",
"return_value",
"=",
"mock_logger",
"mock_object",
"=",
"MockDeprecatedClass",
"(",
")",
"assert",
"mock_object",
".",
"... | [
39,
0
] | [
48,
51
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_substitute_new_class | (mock_get_logger) | Test deprecated class object. | Test deprecated class object. | def test_deprecated_substitute_new_class(mock_get_logger):
"""Test deprecated class object."""
mock_logger = MagicMock()
mock_get_logger.return_value = mock_logger
mock_object = MockUpdatedClass()
assert mock_object.new_property is True
assert mock_object.new_property is True
assert not moc... | [
"def",
"test_deprecated_substitute_new_class",
"(",
"mock_get_logger",
")",
":",
"mock_logger",
"=",
"MagicMock",
"(",
")",
"mock_get_logger",
".",
"return_value",
"=",
"mock_logger",
"mock_object",
"=",
"MockUpdatedClass",
"(",
")",
"assert",
"mock_object",
".",
"new... | [
52,
0
] | [
60,
41
] | python | en | ['en', 'en', 'en'] | True |
test_config_get_deprecated_old | (mock_get_logger) | Test deprecated class object. | Test deprecated class object. | def test_config_get_deprecated_old(mock_get_logger):
"""Test deprecated class object."""
mock_logger = MagicMock()
mock_get_logger.return_value = mock_logger
config = {"old_name": True}
assert get_deprecated(config, "new_name", "old_name") is True
assert mock_logger.warning.called
assert le... | [
"def",
"test_config_get_deprecated_old",
"(",
"mock_get_logger",
")",
":",
"mock_logger",
"=",
"MagicMock",
"(",
")",
"mock_get_logger",
".",
"return_value",
"=",
"mock_logger",
"config",
"=",
"{",
"\"old_name\"",
":",
"True",
"}",
"assert",
"get_deprecated",
"(",
... | [
64,
0
] | [
72,
51
] | python | en | ['en', 'en', 'en'] | True |
test_config_get_deprecated_new | (mock_get_logger) | Test deprecated class object. | Test deprecated class object. | def test_config_get_deprecated_new(mock_get_logger):
"""Test deprecated class object."""
mock_logger = MagicMock()
mock_get_logger.return_value = mock_logger
config = {"new_name": True}
assert get_deprecated(config, "new_name", "old_name") is True
assert not mock_logger.warning.called | [
"def",
"test_config_get_deprecated_new",
"(",
"mock_get_logger",
")",
":",
"mock_logger",
"=",
"MagicMock",
"(",
")",
"mock_get_logger",
".",
"return_value",
"=",
"mock_logger",
"config",
"=",
"{",
"\"new_name\"",
":",
"True",
"}",
"assert",
"get_deprecated",
"(",
... | [
76,
0
] | [
83,
41
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_function | (caplog) | Test deprecated_function decorator. | Test deprecated_function decorator. | def test_deprecated_function(caplog):
"""Test deprecated_function decorator."""
@deprecated_function("new_function")
def mock_deprecated_function():
pass
mock_deprecated_function()
assert (
"mock_deprecated_function is a deprecated function. Use new_function instead"
in cap... | [
"def",
"test_deprecated_function",
"(",
"caplog",
")",
":",
"@",
"deprecated_function",
"(",
"\"new_function\"",
")",
"def",
"mock_deprecated_function",
"(",
")",
":",
"pass",
"mock_deprecated_function",
"(",
")",
"assert",
"(",
"\"mock_deprecated_function is a deprecated... | [
86,
0
] | [
97,
5
] | python | fr | ['fr', 'la', 'pt'] | False |
MockBaseClass.new_property | (self) | Test property to fetch. | Test property to fetch. | def new_property(self):
"""Test property to fetch."""
raise NotImplementedError() | [
"def",
"new_property",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
15,
4
] | [
17,
35
] | python | en | ['en', 'en', 'en'] | True |
MockDeprecatedClass.old_property | (self) | Test property to fetch. | Test property to fetch. | def old_property(self):
"""Test property to fetch."""
return True | [
"def",
"old_property",
"(",
"self",
")",
":",
"return",
"True"
] | [
24,
4
] | [
26,
19
] | python | en | ['en', 'en', 'en'] | True |
MockUpdatedClass.new_property | (self) | Test property to fetch. | Test property to fetch. | def new_property(self):
"""Test property to fetch."""
return True | [
"def",
"new_property",
"(",
"self",
")",
":",
"return",
"True"
] | [
33,
4
] | [
35,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up the NZBGet integration. | Set up the NZBGet integration. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the NZBGet integration."""
hass.data.setdefault(DOMAIN, {})
if hass.config_entries.async_entries(DOMAIN):
return True
if DOMAIN in config:
hass.async_create_task(
hass.config_entries.flow.asyn... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"if",
"hass",
".",
"config_entries",
".",
"async_entrie... | [
63,
0
] | [
79,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up NZBGet from a config entry. | Set up NZBGet from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up NZBGet from a config entry."""
if not entry.options:
options = {
CONF_SCAN_INTERVAL: entry.data.get(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL
),
}
hass.config_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"if",
"not",
"entry",
".",
"options",
":",
"options",
"=",
"{",
"CONF_SCAN_INTERVAL",
":",
"entry",
".",
"data",
".",
"get",
... | [
82,
0
] | [
111,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN][entry.entry_id][DATA_UNDO_UPDATE_LISTENER]()
hass.data[DOMAIN].pop(entry... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"await",
"hass",
".",
"config_entries",
".",
"async_unload_platforms",
"(",
"entry",
",",
"PLATFORMS",
")",
"if... | [
114,
0
] | [
122,
20
] | python | en | ['en', 'es', 'en'] | True |
_async_register_services | (
hass: HomeAssistant,
coordinator: NZBGetDataUpdateCoordinator,
) | Register integration-level services. | Register integration-level services. | def _async_register_services(
hass: HomeAssistant,
coordinator: NZBGetDataUpdateCoordinator,
) -> None:
"""Register integration-level services."""
def pause(call) -> None:
"""Service call to pause downloads in NZBGet."""
coordinator.nzbget.pausedownload()
def resume(call) -> None:
... | [
"def",
"_async_register_services",
"(",
"hass",
":",
"HomeAssistant",
",",
"coordinator",
":",
"NZBGetDataUpdateCoordinator",
",",
")",
"->",
"None",
":",
"def",
"pause",
"(",
"call",
")",
"->",
"None",
":",
"\"\"\"Service call to pause downloads in NZBGet.\"\"\"",
"c... | [
125,
0
] | [
147,
5
] | python | da | ['it', 'da', 'en'] | False |
_async_update_listener | (hass: HomeAssistant, entry: ConfigEntry) | Handle options update. | Handle options update. | async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"_async_update_listener",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
150,
0
] | [
152,
58
] | python | en | ['en', 'nl', 'en'] | True |
NZBGetEntity.__init__ | (
self, *, entry_id: str, name: str, coordinator: NZBGetDataUpdateCoordinator
) | Initialize the NZBGet entity. | Initialize the NZBGet entity. | def __init__(
self, *, entry_id: str, name: str, coordinator: NZBGetDataUpdateCoordinator
) -> None:
"""Initialize the NZBGet entity."""
super().__init__(coordinator)
self._name = name
self._entry_id = entry_id | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"entry_id",
":",
"str",
",",
"name",
":",
"str",
",",
"coordinator",
":",
"NZBGetDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_... | [
158,
4
] | [
164,
33
] | python | en | ['en', 'en', 'en'] | True |
NZBGetEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
167,
4
] | [
169,
25
] | python | en | ['en', 'en', 'en'] | True |
Foo.openapi_types | () |
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
|
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded | def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
retu... | [
"def",
"openapi_types",
"(",
")",
":",
"return",
"{",
"'bar'",
":",
"(",
"str",
",",
")",
",",
"# noqa: E501",
"}"
] | [
64,
4
] | [
75,
9
] | python | en | ['en', 'error', 'th'] | False |
Foo.__init__ | (self, *args, **kwargs) | Foo - a model defined in OpenAPI
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
Defaults... | Foo - a model defined in OpenAPI | def __init__(self, *args, **kwargs): # noqa: E501
"""Foo - a model defined in OpenAPI
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"_check_type",
"=",
"kwargs",
".",
"pop",
"(",
"'_check_type'",
",",
"True",
")",
"_spec_property_naming",
"=",
"kwargs",
".",
"pop",
"(",
"'_spec_property... | [
98,
4
] | [
165,
46
] | python | en | ['en', 'fy', 'en'] | True |
NumberOnly.__init__ | (self, just_number=None, local_vars_configuration=None) | NumberOnly - a model defined in OpenAPI | NumberOnly - a model defined in OpenAPI | def __init__(self, just_number=None, local_vars_configuration=None): # noqa: E501
"""NumberOnly - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
self.local_vars_configuration = local_vars_c... | [
"def",
"__init__",
"(",
"self",
",",
"just_number",
"=",
"None",
",",
"local_vars_configuration",
"=",
"None",
")",
":",
"# noqa: E501",
"# noqa: E501",
"if",
"local_vars_configuration",
"is",
"None",
":",
"local_vars_configuration",
"=",
"Configuration",
".",
"get_... | [
42,
4
] | [
52,
42
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.just_number | (self) | Gets the just_number of this NumberOnly. # noqa: E501
:return: The just_number of this NumberOnly. # noqa: E501
:rtype: float
| Gets the just_number of this NumberOnly. # noqa: E501 | def just_number(self):
"""Gets the just_number of this NumberOnly. # noqa: E501
:return: The just_number of this NumberOnly. # noqa: E501
:rtype: float
"""
return self._just_number | [
"def",
"just_number",
"(",
"self",
")",
":",
"return",
"self",
".",
"_just_number"
] | [
55,
4
] | [
62,
32
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.just_number | (self, just_number) | Sets the just_number of this NumberOnly.
:param just_number: The just_number of this NumberOnly. # noqa: E501
:type just_number: float
| Sets the just_number of this NumberOnly. | def just_number(self, just_number):
"""Sets the just_number of this NumberOnly.
:param just_number: The just_number of this NumberOnly. # noqa: E501
:type just_number: float
"""
self._just_number = just_number | [
"def",
"just_number",
"(",
"self",
",",
"just_number",
")",
":",
"self",
".",
"_just_number",
"=",
"just_number"
] | [
65,
4
] | [
73,
39
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.to_dict | (self, serialize=False) | Returns the model properties as a dict | Returns the model properties as a dict | def to_dict(self, serialize=False):
"""Returns the model properties as a dict"""
result = {}
def convert(x):
if hasattr(x, "to_dict"):
args = inspect.getargspec(x.to_dict).args
if len(args) == 1:
return x.to_dict()
... | [
"def",
"to_dict",
"(",
"self",
",",
"serialize",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"def",
"convert",
"(",
"x",
")",
":",
"if",
"hasattr",
"(",
"x",
",",
"\"to_dict\"",
")",
":",
"args",
"=",
"inspect",
".",
"getargspec",
"(",
"x",
... | [
75,
4
] | [
105,
21
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.to_str | (self) | Returns the string representation of the model | Returns the string representation of the model | def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict()) | [
"def",
"to_str",
"(",
"self",
")",
":",
"return",
"pprint",
".",
"pformat",
"(",
"self",
".",
"to_dict",
"(",
")",
")"
] | [
107,
4
] | [
109,
45
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.__repr__ | (self) | For `print` and `pprint` | For `print` and `pprint` | def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str() | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"self",
".",
"to_str",
"(",
")"
] | [
111,
4
] | [
113,
28
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.__eq__ | (self, other) | Returns true if both objects are equal | Returns true if both objects are equal | def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, NumberOnly):
return False
return self.to_dict() == other.to_dict() | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NumberOnly",
")",
":",
"return",
"False",
"return",
"self",
".",
"to_dict",
"(",
")",
"==",
"other",
".",
"to_dict",
"(",
")"
] | [
115,
4
] | [
120,
48
] | python | en | ['en', 'en', 'en'] | True |
NumberOnly.__ne__ | (self, other) | Returns true if both objects are not equal | Returns true if both objects are not equal | def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, NumberOnly):
return True
return self.to_dict() != other.to_dict() | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NumberOnly",
")",
":",
"return",
"True",
"return",
"self",
".",
"to_dict",
"(",
")",
"!=",
"other",
".",
"to_dict",
"(",
")"
] | [
122,
4
] | [
127,
48
] | python | en | ['en', 'en', 'en'] | True |
async_setup_scanner | (hass, config, async_see, discovery_info=None) | Set up the Volvo tracker. | Set up the Volvo tracker. | async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Set up the Volvo tracker."""
if discovery_info is None:
return
vin, component, attr = discovery_info
data = hass.data[DATA_KEY]
instrument = data.instrument(vin, component, attr)
async def see_vehicle():
... | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
",",
"config",
",",
"async_see",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"vin",
",",
"component",
",",
"attr",
"=",
"discovery_info",
"data",
"=",
... | [
8,
0
] | [
31,
15
] | python | en | ['en', 'en', 'en'] | True |
color_name_to_rgb | (color_name: str) | Convert color name to RGB hex value. | Convert color name to RGB hex value. | def color_name_to_rgb(color_name: str) -> RGBColor:
"""Convert color name to RGB hex value."""
# COLORS map has no spaces in it, so make the color_name have no
# spaces in it as well for matching purposes
hex_value = COLORS.get(color_name.replace(" ", "").lower())
if not hex_value:
raise Val... | [
"def",
"color_name_to_rgb",
"(",
"color_name",
":",
"str",
")",
"->",
"RGBColor",
":",
"# COLORS map has no spaces in it, so make the color_name have no",
"# spaces in it as well for matching purposes",
"hex_value",
"=",
"COLORS",
".",
"get",
"(",
"color_name",
".",
"replace"... | [
198,
0
] | [
206,
20
] | python | en | ['en', 'en', 'en'] | True |
color_RGB_to_xy | (
iR: int, iG: int, iB: int, Gamut: GamutType | None = None
) | Convert from RGB color to XY color. | Convert from RGB color to XY color. | def color_RGB_to_xy(
iR: int, iG: int, iB: int, Gamut: GamutType | None = None
) -> tuple[float, float]:
"""Convert from RGB color to XY color."""
return color_RGB_to_xy_brightness(iR, iG, iB, Gamut)[:2] | [
"def",
"color_RGB_to_xy",
"(",
"iR",
":",
"int",
",",
"iG",
":",
"int",
",",
"iB",
":",
"int",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
"]",
":",
"return",
"color_RGB_to_xy_brightness",
... | [
212,
0
] | [
216,
60
] | python | en | ['en', 'en', 'en'] | True |
color_RGB_to_xy_brightness | (
iR: int, iG: int, iB: int, Gamut: GamutType | None = None
) | Convert from RGB color to XY color. | Convert from RGB color to XY color. | def color_RGB_to_xy_brightness(
iR: int, iG: int, iB: int, Gamut: GamutType | None = None
) -> tuple[float, float, int]:
"""Convert from RGB color to XY color."""
if iR + iG + iB == 0:
return 0.0, 0.0, 0
R = iR / 255
B = iB / 255
G = iG / 255
# Gamma correction
R = pow((R + 0.0... | [
"def",
"color_RGB_to_xy_brightness",
"(",
"iR",
":",
"int",
",",
"iG",
":",
"int",
",",
"iB",
":",
"int",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
",",
"int",
"]",
":",
"if",
"iR",
... | [
222,
0
] | [
259,
47
] | python | en | ['en', 'en', 'en'] | True |
color_xy_to_RGB | (
vX: float, vY: float, Gamut: GamutType | None = None
) | Convert from XY to a normalized RGB. | Convert from XY to a normalized RGB. | def color_xy_to_RGB(
vX: float, vY: float, Gamut: GamutType | None = None
) -> tuple[int, int, int]:
"""Convert from XY to a normalized RGB."""
return color_xy_brightness_to_RGB(vX, vY, 255, Gamut) | [
"def",
"color_xy_to_RGB",
"(",
"vX",
":",
"float",
",",
"vY",
":",
"float",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"return",
"color_xy_brightness_to_RGB",
"(",
"vX",
... | [
262,
0
] | [
266,
57
] | python | en | ['en', 'en', 'en'] | True |
color_xy_brightness_to_RGB | (
vX: float, vY: float, ibrightness: int, Gamut: GamutType | None = None
) | Convert from XYZ to RGB. | Convert from XYZ to RGB. | def color_xy_brightness_to_RGB(
vX: float, vY: float, ibrightness: int, Gamut: GamutType | None = None
) -> tuple[int, int, int]:
"""Convert from XYZ to RGB."""
if Gamut and not check_point_in_lamps_reach((vX, vY), Gamut):
xy_closest = get_closest_point_to_point((vX, vY), Gamut)
vX = xy_clos... | [
"def",
"color_xy_brightness_to_RGB",
"(",
"vX",
":",
"float",
",",
"vY",
":",
"float",
",",
"ibrightness",
":",
"int",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"if",
... | [
271,
0
] | [
315,
23
] | python | en | ['en', 'en', 'en'] | True |
color_hsb_to_RGB | (fH: float, fS: float, fB: float) | Convert a hsb into its rgb representation. | Convert a hsb into its rgb representation. | def color_hsb_to_RGB(fH: float, fS: float, fB: float) -> tuple[int, int, int]:
"""Convert a hsb into its rgb representation."""
if fS == 0.0:
fV = int(fB * 255)
return fV, fV, fV
r = g = b = 0
h = fH / 60
f = h - float(math.floor(h))
p = fB * (1 - fS)
q = fB * (1 - fS * f)
... | [
"def",
"color_hsb_to_RGB",
"(",
"fH",
":",
"float",
",",
"fS",
":",
"float",
",",
"fB",
":",
"float",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"if",
"fS",
"==",
"0.0",
":",
"fV",
"=",
"int",
"(",
"fB",
"*",
"255",
")"... | [
318,
0
] | [
356,
20
] | python | en | ['en', 'ca', 'en'] | True |
color_RGB_to_hsv | (iR: float, iG: float, iB: float) | Convert an rgb color to its hsv representation.
Hue is scaled 0-360
Sat is scaled 0-100
Val is scaled 0-100
| Convert an rgb color to its hsv representation. | def color_RGB_to_hsv(iR: float, iG: float, iB: float) -> tuple[float, float, float]:
"""Convert an rgb color to its hsv representation.
Hue is scaled 0-360
Sat is scaled 0-100
Val is scaled 0-100
"""
fHSV = colorsys.rgb_to_hsv(iR / 255.0, iG / 255.0, iB / 255.0)
return round(fHSV[0] * 360, ... | [
"def",
"color_RGB_to_hsv",
"(",
"iR",
":",
"float",
",",
"iG",
":",
"float",
",",
"iB",
":",
"float",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"fHSV",
"=",
"colorsys",
".",
"rgb_to_hsv",
"(",
"iR",
"/",
"255.0",
",",
... | [
359,
0
] | [
367,
84
] | python | en | ['en', 'en', 'en'] | True |
color_RGB_to_hs | (iR: float, iG: float, iB: float) | Convert an rgb color to its hs representation. | Convert an rgb color to its hs representation. | def color_RGB_to_hs(iR: float, iG: float, iB: float) -> tuple[float, float]:
"""Convert an rgb color to its hs representation."""
return color_RGB_to_hsv(iR, iG, iB)[:2] | [
"def",
"color_RGB_to_hs",
"(",
"iR",
":",
"float",
",",
"iG",
":",
"float",
",",
"iB",
":",
"float",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
"]",
":",
"return",
"color_RGB_to_hsv",
"(",
"iR",
",",
"iG",
",",
"iB",
")",
"[",
":",
"2",
"]"
... | [
370,
0
] | [
372,
43
] | python | en | ['en', 'en', 'en'] | True |
color_hsv_to_RGB | (iH: float, iS: float, iV: float) | Convert an hsv color into its rgb representation.
Hue is scaled 0-360
Sat is scaled 0-100
Val is scaled 0-100
| Convert an hsv color into its rgb representation. | def color_hsv_to_RGB(iH: float, iS: float, iV: float) -> tuple[int, int, int]:
"""Convert an hsv color into its rgb representation.
Hue is scaled 0-360
Sat is scaled 0-100
Val is scaled 0-100
"""
fRGB = colorsys.hsv_to_rgb(iH / 360, iS / 100, iV / 100)
return (int(fRGB[0] * 255), int(fRGB[1... | [
"def",
"color_hsv_to_RGB",
"(",
"iH",
":",
"float",
",",
"iS",
":",
"float",
",",
"iV",
":",
"float",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"fRGB",
"=",
"colorsys",
".",
"hsv_to_rgb",
"(",
"iH",
"/",
"360",
",",
"iS",
... | [
375,
0
] | [
383,
71
] | python | en | ['en', 'ca', 'en'] | True |
color_hs_to_RGB | (iH: float, iS: float) | Convert an hsv color into its rgb representation. | Convert an hsv color into its rgb representation. | def color_hs_to_RGB(iH: float, iS: float) -> tuple[int, int, int]:
"""Convert an hsv color into its rgb representation."""
return color_hsv_to_RGB(iH, iS, 100) | [
"def",
"color_hs_to_RGB",
"(",
"iH",
":",
"float",
",",
"iS",
":",
"float",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"return",
"color_hsv_to_RGB",
"(",
"iH",
",",
"iS",
",",
"100",
")"
] | [
386,
0
] | [
388,
40
] | python | en | ['en', 'ca', 'en'] | True |
color_xy_to_hs | (
vX: float, vY: float, Gamut: GamutType | None = None
) | Convert an xy color to its hs representation. | Convert an xy color to its hs representation. | def color_xy_to_hs(
vX: float, vY: float, Gamut: GamutType | None = None
) -> tuple[float, float]:
"""Convert an xy color to its hs representation."""
h, s, _ = color_RGB_to_hsv(*color_xy_to_RGB(vX, vY, Gamut))
return h, s | [
"def",
"color_xy_to_hs",
"(",
"vX",
":",
"float",
",",
"vY",
":",
"float",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
"]",
":",
"h",
",",
"s",
",",
"_",
"=",
"color_RGB_to_hsv",
"(",
... | [
391,
0
] | [
396,
15
] | python | en | ['en', 'en', 'en'] | True |
color_hs_to_xy | (
iH: float, iS: float, Gamut: GamutType | None = None
) | Convert an hs color to its xy representation. | Convert an hs color to its xy representation. | def color_hs_to_xy(
iH: float, iS: float, Gamut: GamutType | None = None
) -> tuple[float, float]:
"""Convert an hs color to its xy representation."""
return color_RGB_to_xy(*color_hs_to_RGB(iH, iS), Gamut) | [
"def",
"color_hs_to_xy",
"(",
"iH",
":",
"float",
",",
"iS",
":",
"float",
",",
"Gamut",
":",
"GamutType",
"|",
"None",
"=",
"None",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
"]",
":",
"return",
"color_RGB_to_xy",
"(",
"*",
"color_hs_to_RGB",
"("... | [
399,
0
] | [
403,
59
] | python | en | ['en', 'en', 'en'] | True |
_match_max_scale | (
input_colors: tuple[int, ...], output_colors: tuple[int, ...]
) | Match the maximum value of the output to the input. | Match the maximum value of the output to the input. | def _match_max_scale(
input_colors: tuple[int, ...], output_colors: tuple[int, ...]
) -> tuple[int, ...]:
"""Match the maximum value of the output to the input."""
max_in = max(input_colors)
max_out = max(output_colors)
if max_out == 0:
factor = 0.0
else:
factor = max_in / max_ou... | [
"def",
"_match_max_scale",
"(",
"input_colors",
":",
"tuple",
"[",
"int",
",",
"...",
"]",
",",
"output_colors",
":",
"tuple",
"[",
"int",
",",
"...",
"]",
")",
"->",
"tuple",
"[",
"int",
",",
"...",
"]",
":",
"max_in",
"=",
"max",
"(",
"input_colors... | [
406,
0
] | [
416,
63
] | python | en | ['en', 'en', 'en'] | True |
color_rgb_to_rgbw | (r: int, g: int, b: int) | Convert an rgb color to an rgbw representation. | Convert an rgb color to an rgbw representation. | def color_rgb_to_rgbw(r: int, g: int, b: int) -> tuple[int, int, int, int]:
"""Convert an rgb color to an rgbw representation."""
# Calculate the white channel as the minimum of input rgb channels.
# Subtract the white portion from the remaining rgb channels.
w = min(r, g, b)
rgbw = (r - w, g - w, b... | [
"def",
"color_rgb_to_rgbw",
"(",
"r",
":",
"int",
",",
"g",
":",
"int",
",",
"b",
":",
"int",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
",",
"int",
"]",
":",
"# Calculate the white channel as the minimum of input rgb channels.",
"# Subtract the w... | [
419,
0
] | [
428,
44
] | python | en | ['en', 'en', 'en'] | True |
color_rgbw_to_rgb | (r: int, g: int, b: int, w: int) | Convert an rgbw color to an rgb representation. | Convert an rgbw color to an rgb representation. | def color_rgbw_to_rgb(r: int, g: int, b: int, w: int) -> tuple[int, int, int]:
"""Convert an rgbw color to an rgb representation."""
# Add the white channel to the rgb channels.
rgb = (r + w, g + w, b + w)
# Match the output maximum value to the input. This ensures the
# output doesn't overflow.
... | [
"def",
"color_rgbw_to_rgb",
"(",
"r",
":",
"int",
",",
"g",
":",
"int",
",",
"b",
":",
"int",
",",
"w",
":",
"int",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
":",
"# Add the white channel to the rgb channels.",
"rgb",
"=",
"(",
"r"... | [
431,
0
] | [
438,
46
] | python | en | ['en', 'en', 'en'] | True |
color_rgb_to_rgbww | (
r: int, g: int, b: int, min_mireds: int, max_mireds: int
) | Convert an rgb color to an rgbww representation. | Convert an rgb color to an rgbww representation. | def color_rgb_to_rgbww(
r: int, g: int, b: int, min_mireds: int, max_mireds: int
) -> tuple[int, int, int, int, int]:
"""Convert an rgb color to an rgbww representation."""
# Find the color temperature when both white channels have equal brightness
mired_range = max_mireds - min_mireds
mired_midpoin... | [
"def",
"color_rgb_to_rgbww",
"(",
"r",
":",
"int",
",",
"g",
":",
"int",
",",
"b",
":",
"int",
",",
"min_mireds",
":",
"int",
",",
"max_mireds",
":",
"int",
")",
"->",
"tuple",
"[",
"int",
",",
"int",
",",
"int",
",",
"int",
",",
"int",
"]",
":... | [
441,
0
] | [
460,
45
] | python | en | ['en', 'en', 'en'] | True |
color_rgbww_to_rgb | (
r: int, g: int, b: int, cw: int, ww: int, min_mireds: int, max_mireds: int
) | Convert an rgbww color to an rgb representation. | Convert an rgbww color to an rgb representation. | def color_rgbww_to_rgb(
r: int, g: int, b: int, cw: int, ww: int, min_mireds: int, max_mireds: int
) -> tuple[int, int, int]:
"""Convert an rgbww color to an rgb representation."""
# Calculate color temperature of the white channels
mired_range = max_mireds - min_mireds
try:
ct_ratio = ww / ... | [
"def",
"color_rgbww_to_rgb",
"(",
"r",
":",
"int",
",",
"g",
":",
"int",
",",
"b",
":",
"int",
",",
"cw",
":",
"int",
",",
"ww",
":",
"int",
",",
"min_mireds",
":",
"int",
",",
"max_mireds",
":",
"int",
")",
"->",
"tuple",
"[",
"int",
",",
"int... | [
463,
0
] | [
483,
51
] | python | en | ['en', 'en', 'en'] | True |
color_rgb_to_hex | (r: int, g: int, b: int) | Return a RGB color from a hex color string. | Return a RGB color from a hex color string. | def color_rgb_to_hex(r: int, g: int, b: int) -> str:
"""Return a RGB color from a hex color string."""
return f"{round(r):02x}{round(g):02x}{round(b):02x}" | [
"def",
"color_rgb_to_hex",
"(",
"r",
":",
"int",
",",
"g",
":",
"int",
",",
"b",
":",
"int",
")",
"->",
"str",
":",
"return",
"f\"{round(r):02x}{round(g):02x}{round(b):02x}\""
] | [
486,
0
] | [
488,
56
] | python | en | ['en', 'en', 'en'] | True |
rgb_hex_to_rgb_list | (hex_string: str) | Return an RGB color value list from a hex color string. | Return an RGB color value list from a hex color string. | def rgb_hex_to_rgb_list(hex_string: str) -> list[int]:
"""Return an RGB color value list from a hex color string."""
return [
int(hex_string[i : i + len(hex_string) // 3], 16)
for i in range(0, len(hex_string), len(hex_string) // 3)
] | [
"def",
"rgb_hex_to_rgb_list",
"(",
"hex_string",
":",
"str",
")",
"->",
"list",
"[",
"int",
"]",
":",
"return",
"[",
"int",
"(",
"hex_string",
"[",
"i",
":",
"i",
"+",
"len",
"(",
"hex_string",
")",
"//",
"3",
"]",
",",
"16",
")",
"for",
"i",
"in... | [
491,
0
] | [
496,
5
] | python | en | ['en', 'en', 'en'] | True |
color_temperature_to_hs | (color_temperature_kelvin: float) | Return an hs color from a color temperature in Kelvin. | Return an hs color from a color temperature in Kelvin. | def color_temperature_to_hs(color_temperature_kelvin: float) -> tuple[float, float]:
"""Return an hs color from a color temperature in Kelvin."""
return color_RGB_to_hs(*color_temperature_to_rgb(color_temperature_kelvin)) | [
"def",
"color_temperature_to_hs",
"(",
"color_temperature_kelvin",
":",
"float",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
"]",
":",
"return",
"color_RGB_to_hs",
"(",
"*",
"color_temperature_to_rgb",
"(",
"color_temperature_kelvin",
")",
")"
] | [
499,
0
] | [
501,
79
] | python | en | ['en', 'en', 'en'] | True |
color_temperature_to_rgb | (
color_temperature_kelvin: float,
) |
Return an RGB color from a color temperature in Kelvin.
This is a rough approximation based on the formula provided by T. Helland
http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
|
Return an RGB color from a color temperature in Kelvin. | def color_temperature_to_rgb(
color_temperature_kelvin: float,
) -> tuple[float, float, float]:
"""
Return an RGB color from a color temperature in Kelvin.
This is a rough approximation based on the formula provided by T. Helland
http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-c... | [
"def",
"color_temperature_to_rgb",
"(",
"color_temperature_kelvin",
":",
"float",
",",
")",
"->",
"tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"# range check",
"if",
"color_temperature_kelvin",
"<",
"1000",
":",
"color_temperature_kelvin",
"=",
"10... | [
504,
0
] | [
527,
27
] | python | en | ['en', 'error', 'th'] | False |
_clamp | (color_component: float, minimum: float = 0, maximum: float = 255) |
Clamp the given color component value between the given min and max values.
The range defined by the minimum and maximum values is inclusive, i.e. given a
color_component of 0 and a minimum of 10, the returned value is 10.
|
Clamp the given color component value between the given min and max values. | def _clamp(color_component: float, minimum: float = 0, maximum: float = 255) -> float:
"""
Clamp the given color component value between the given min and max values.
The range defined by the minimum and maximum values is inclusive, i.e. given a
color_component of 0 and a minimum of 10, the returned va... | [
"def",
"_clamp",
"(",
"color_component",
":",
"float",
",",
"minimum",
":",
"float",
"=",
"0",
",",
"maximum",
":",
"float",
"=",
"255",
")",
"->",
"float",
":",
"color_component_out",
"=",
"max",
"(",
"color_component",
",",
"minimum",
")",
"return",
"m... | [
530,
0
] | [
538,
44
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.