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
test_redact_exclude_no_regex
(_process_content_redaction)
Verify that the _process_content_redaction call is made with exclude == list of strings and regex == False when a list of pattern strings is defined in rm_conf
Verify that the _process_content_redaction call is made with exclude == list of strings and regex == False when a list of pattern strings is defined in rm_conf
def test_redact_exclude_no_regex(_process_content_redaction): ''' Verify that the _process_content_redaction call is made with exclude == list of strings and regex == False when a list of pattern strings is defined in rm_conf ''' conf = InsightsConfig() arch = InsightsArchive(conf) arch....
[ "def", "test_redact_exclude_no_regex", "(", "_process_content_redaction", ")", ":", "conf", "=", "InsightsConfig", "(", ")", "arch", "=", "InsightsArchive", "(", "conf", ")", "arch", ".", "create_archive_dir", "(", ")", "# put something in the archive to redact", "test_...
[ 155, 0 ]
[ 180, 94 ]
python
en
['en', 'error', 'th']
False
test_redact_exclude_empty
(_process_content_redaction)
Verify that the _process_content_redaction call is made with exclude == [] and regex == False when the patterns key is defined but value is an empty list
Verify that the _process_content_redaction call is made with exclude == [] and regex == False when the patterns key is defined but value is an empty list
def test_redact_exclude_empty(_process_content_redaction): ''' Verify that the _process_content_redaction call is made with exclude == [] and regex == False when the patterns key is defined but value is an empty list ''' conf = InsightsConfig() arch = InsightsArchive(conf) arch.create_ar...
[ "def", "test_redact_exclude_empty", "(", "_process_content_redaction", ")", ":", "conf", "=", "InsightsConfig", "(", ")", "arch", "=", "InsightsArchive", "(", "conf", ")", "arch", ".", "create_archive_dir", "(", ")", "# put something in the archive to redact", "test_fil...
[ 184, 0 ]
[ 209, 80 ]
python
en
['en', 'error', 'th']
False
test_redact_exclude_none
(_process_content_redaction)
Verify that the _process_content_redaction call is made with exclude == None and regex == False when the patterns key is defined but value is an empty dict
Verify that the _process_content_redaction call is made with exclude == None and regex == False when the patterns key is defined but value is an empty dict
def test_redact_exclude_none(_process_content_redaction): ''' Verify that the _process_content_redaction call is made with exclude == None and regex == False when the patterns key is defined but value is an empty dict ''' conf = InsightsConfig() arch = InsightsArchive(conf) arch.create_a...
[ "def", "test_redact_exclude_none", "(", "_process_content_redaction", ")", ":", "conf", "=", "InsightsConfig", "(", ")", "arch", "=", "InsightsArchive", "(", "conf", ")", "arch", ".", "create_archive_dir", "(", ")", "# put something in the archive to redact", "test_file...
[ 213, 0 ]
[ 238, 82 ]
python
en
['en', 'error', 'th']
False
test_redact_bad_location
(_process_content_redaction, walk)
Verify that redact() raises a RuntimeError if the directory present in InsightsArchive is in a location other than /var/tmp/**/insights-*
Verify that redact() raises a RuntimeError if the directory present in InsightsArchive is in a location other than /var/tmp/**/insights-*
def test_redact_bad_location(_process_content_redaction, walk): ''' Verify that redact() raises a RuntimeError if the directory present in InsightsArchive is in a location other than /var/tmp/**/insights-* ''' conf = InsightsConfig() arch = InsightsArchive(conf) for bad_path in ['/', '/...
[ "def", "test_redact_bad_location", "(", "_process_content_redaction", ",", "walk", ")", ":", "conf", "=", "InsightsConfig", "(", ")", "arch", "=", "InsightsArchive", "(", "conf", ")", "for", "bad_path", "in", "[", "'/'", ",", "'/home'", ",", "'/etc'", ",", "...
[ 243, 0 ]
[ 259, 54 ]
python
en
['en', 'error', 'th']
False
TestFoo.make_instance
(self, include_optional)
Test Foo include_option is a boolean, when False only required params are included, when True both required and optional params are included
Test Foo include_option is a boolean, when False only required params are included, when True both required and optional params are included
def make_instance(self, include_optional): """Test Foo include_option is a boolean, when False only required params are included, when True both required and optional params are included """ # model = petstore_api.models.foo.Foo() # noqa: E501 if include_opti...
[ "def", "make_instance", "(", "self", ",", "include_optional", ")", ":", "# model = petstore_api.models.foo.Foo() # noqa: E501", "if", "include_optional", ":", "return", "Foo", "(", "bar", "=", "'bar'", ")", "else", ":", "return", "Foo", "(", ")" ]
[ 30, 4 ]
[ 42, 9 ]
python
en
['en', 'et', 'ur']
False
valid_integration
(integration)
Test if it's a valid integration.
Test if it's a valid integration.
def valid_integration(integration): """Test if it's a valid integration.""" if not (INTEGRATIONS_DIR / integration).is_dir(): raise argparse.ArgumentTypeError( f"The integration {integration} does not exist." ) return integration
[ "def", "valid_integration", "(", "integration", ")", ":", "if", "not", "(", "INTEGRATIONS_DIR", "/", "integration", ")", ".", "is_dir", "(", ")", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "f\"The integration {integration} does not exist.\"", ")", "ret...
[ 13, 0 ]
[ 20, 22 ]
python
en
['en', 'en', 'en']
True
get_arguments
()
Get parsed passed in arguments.
Get parsed passed in arguments.
def get_arguments() -> argparse.Namespace: """Get parsed passed in arguments.""" parser = get_base_arg_parser() parser.add_argument( "--integration", type=valid_integration, help="Integration to process." ) return parser.parse_args()
[ "def", "get_arguments", "(", ")", "->", "argparse", ".", "Namespace", ":", "parser", "=", "get_base_arg_parser", "(", ")", "parser", ".", "add_argument", "(", "\"--integration\"", ",", "type", "=", "valid_integration", ",", "help", "=", "\"Integration to process.\...
[ 23, 0 ]
[ 29, 30 ]
python
en
['en', 'la', 'en']
True
flatten_translations
(translations)
Flatten all translations.
Flatten all translations.
def flatten_translations(translations): """Flatten all translations.""" stack = [iter(translations.items())] key_stack = [] flattened_translations = {} while stack: for k, v in stack[-1]: key_stack.append(k) if isinstance(v, dict): stack.append(iter(v....
[ "def", "flatten_translations", "(", "translations", ")", ":", "stack", "=", "[", "iter", "(", "translations", ".", "items", "(", ")", ")", "]", "key_stack", "=", "[", "]", "flattened_translations", "=", "{", "}", "while", "stack", ":", "for", "k", ",", ...
[ 32, 0 ]
[ 52, 33 ]
python
en
['en', 'bg', 'en']
True
substitute_translation_references
(integration_strings, flattened_translations)
Recursively processes all translation strings for the integration.
Recursively processes all translation strings for the integration.
def substitute_translation_references(integration_strings, flattened_translations): """Recursively processes all translation strings for the integration.""" result = {} for key, value in integration_strings.items(): if isinstance(value, dict): sub_dict = substitute_translation_references...
[ "def", "substitute_translation_references", "(", "integration_strings", ",", "flattened_translations", ")", ":", "result", "=", "{", "}", "for", "key", ",", "value", "in", "integration_strings", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",",...
[ 55, 0 ]
[ 65, 17 ]
python
en
['en', 'en', 'en']
True
substitute_reference
(value, flattened_translations)
Substitute localization key references in a translation string.
Substitute localization key references in a translation string.
def substitute_reference(value, flattened_translations): """Substitute localization key references in a translation string.""" matches = re.findall(r"\[\%key:((?:[\w]+|[:]{2})*)\%\]", value) if not matches: return value new = value for key in matches: if key in flattened_translation...
[ "def", "substitute_reference", "(", "value", ",", "flattened_translations", ")", ":", "matches", "=", "re", ".", "findall", "(", "r\"\\[\\%key:((?:[\\w]+|[:]{2})*)\\%\\]\"", ",", "value", ")", "if", "not", "matches", ":", "return", "value", "new", "=", "value", ...
[ 68, 0 ]
[ 82, 14 ]
python
en
['en', 'en', 'en']
True
run
()
Run the script.
Run the script.
def run(): """Run the script.""" args = get_arguments() if args.integration: integration = args.integration else: integration = None while ( integration is None or not Path(f"homeassistant/components/{integration}").exists() ): if integ...
[ "def", "run", "(", ")", ":", "args", "=", "get_arguments", "(", ")", "if", "args", ".", "integration", ":", "integration", "=", "args", ".", "integration", "else", ":", "integration", "=", "None", "while", "(", "integration", "is", "None", "or", "not", ...
[ 85, 0 ]
[ 125, 12 ]
python
en
['en', 'co', 'en']
True
zipfile_factory
(file, *args, **kwargs)
Create a ZipFile. Allows for Zip64, and the `file` argument can accept file, str, or pathlib.Path objects. `args` and `kwargs` are passed to the zipfile.ZipFile constructor.
Create a ZipFile.
def zipfile_factory(file, *args, **kwargs): """ Create a ZipFile. Allows for Zip64, and the `file` argument can accept file, str, or pathlib.Path objects. `args` and `kwargs` are passed to the zipfile.ZipFile constructor. """ if not hasattr(file, 'read'): file = os_fspath(file) ...
[ "def", "zipfile_factory", "(", "file", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "file", ",", "'read'", ")", ":", "file", "=", "os_fspath", "(", "file", ")", "import", "zipfile", "kwargs", "[", "'allowZip64'", ...
[ 99, 0 ]
[ 111, 49 ]
python
en
['en', 'error', 'th']
False
load
(file, mmap_mode=None, allow_pickle=False, fix_imports=True, encoding='ASCII')
Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files. .. warning:: Loading files that contain object arrays uses the ``pickle`` module, which is not secure against erroneous or maliciously constructed data. Consider passing ``allow_pickle=False`` to ...
Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files.
def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True, encoding='ASCII'): """ Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files. .. warning:: Loading files that contain object arrays uses the ``pickle`` module, which is not secure against errone...
[ "def", "load", "(", "file", ",", "mmap_mode", "=", "None", ",", "allow_pickle", "=", "False", ",", "fix_imports", "=", "True", ",", "encoding", "=", "'ASCII'", ")", ":", "if", "encoding", "not", "in", "(", "'ASCII'", ",", "'latin1'", ",", "'bytes'", ")...
[ 283, 0 ]
[ 449, 75 ]
python
en
['en', 'error', 'th']
False
save
(file, arr, allow_pickle=True, fix_imports=True)
Save an array to a binary file in NumPy ``.npy`` format. Parameters ---------- file : file, str, or pathlib.Path File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string or Path, a ``.npy`` extension will be ap...
Save an array to a binary file in NumPy ``.npy`` format.
def save(file, arr, allow_pickle=True, fix_imports=True): """ Save an array to a binary file in NumPy ``.npy`` format. Parameters ---------- file : file, str, or pathlib.Path File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If ...
[ "def", "save", "(", "file", ",", "arr", ",", "allow_pickle", "=", "True", ",", "fix_imports", "=", "True", ")", ":", "if", "hasattr", "(", "file", ",", "'write'", ")", ":", "file_ctx", "=", "contextlib_nullcontext", "(", "file", ")", "else", ":", "file...
[ 457, 0 ]
[ 528, 71 ]
python
en
['en', 'error', 'th']
False
savez
(file, *args, **kwds)
Save several arrays into a single file in uncompressed ``.npz`` format. If arguments are passed in with no keywords, the corresponding variable names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword arguments are given, the corresponding variable names, in the ``.npz`` file will match the k...
Save several arrays into a single file in uncompressed ``.npz`` format.
def savez(file, *args, **kwds): """Save several arrays into a single file in uncompressed ``.npz`` format. If arguments are passed in with no keywords, the corresponding variable names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword arguments are given, the corresponding variable names, in...
[ "def", "savez", "(", "file", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "_savez", "(", "file", ",", "args", ",", "kwds", ",", "False", ")" ]
[ 537, 0 ]
[ 615, 35 ]
python
en
['en', 'en', 'en']
True
savez_compressed
(file, *args, **kwds)
Save several arrays into a single file in compressed ``.npz`` format. If keyword arguments are given, then filenames are taken from the keywords. If arguments are passed in with no keywords, then stored filenames are arr_0, arr_1, etc. Parameters ---------- file : str or file Eith...
Save several arrays into a single file in compressed ``.npz`` format.
def savez_compressed(file, *args, **kwds): """ Save several arrays into a single file in compressed ``.npz`` format. If keyword arguments are given, then filenames are taken from the keywords. If arguments are passed in with no keywords, then stored filenames are arr_0, arr_1, etc. Parameters ...
[ "def", "savez_compressed", "(", "file", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "_savez", "(", "file", ",", "args", ",", "kwds", ",", "True", ")" ]
[ 624, 0 ]
[ 685, 34 ]
python
en
['en', 'error', 'th']
False
_getconv
(dtype)
Find the correct dtype converter. Adapted from matplotlib
Find the correct dtype converter. Adapted from matplotlib
def _getconv(dtype): """ Find the correct dtype converter. Adapted from matplotlib """ def floatconv(x): x.lower() if '0x' in x: return float.fromhex(x) return float(x) typ = dtype.type if issubclass(typ, np.bool_): return lambda x: bool(int(x)) if issub...
[ "def", "_getconv", "(", "dtype", ")", ":", "def", "floatconv", "(", "x", ")", ":", "x", ".", "lower", "(", ")", "if", "'0x'", "in", "x", ":", "return", "float", ".", "fromhex", "(", "x", ")", "return", "float", "(", "x", ")", "typ", "=", "dtype...
[ 755, 0 ]
[ 784, 20 ]
python
en
['en', 'en', 'en']
True
loadtxt
(fname, dtype=float, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0, encoding='bytes', max_rows=None)
r""" Load data from a text file. Each row in the text file must have the same number of values. Parameters ---------- fname : file, str, or pathlib.Path File, filename, or generator to read. If the filename extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note tha...
r""" Load data from a text file.
def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0, encoding='bytes', max_rows=None): r""" Load data from a text file. Each row in the text file must have the same number of values. Parameters -----...
[ "def", "loadtxt", "(", "fname", ",", "dtype", "=", "float", ",", "comments", "=", "'#'", ",", "delimiter", "=", "None", ",", "converters", "=", "None", ",", "skiprows", "=", "0", ",", "usecols", "=", "None", ",", "unpack", "=", "False", ",", "ndmin",...
[ 791, 0 ]
[ 1181, 16 ]
python
cy
['en', 'cy', 'hi']
False
savetxt
(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# ', encoding=None)
Save an array to a text file. Parameters ---------- fname : filename or file handle If the filename ends in ``.gz``, the file is automatically saved in compressed gzip format. `loadtxt` understands gzipped files transparently. X : 1D or 2D array_like Data to be sav...
Save an array to a text file.
def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# ', encoding=None): """ Save an array to a text file. Parameters ---------- fname : filename or file handle If the filename ends in ``.gz``, the file is automatically saved in ...
[ "def", "savetxt", "(", "fname", ",", "X", ",", "fmt", "=", "'%.18e'", ",", "delimiter", "=", "' '", ",", "newline", "=", "'\\n'", ",", "header", "=", "''", ",", "footer", "=", "''", ",", "comments", "=", "'# '", ",", "encoding", "=", "None", ")", ...
[ 1191, 0 ]
[ 1435, 22 ]
python
en
['en', 'error', 'th']
False
fromregex
(file, regexp, dtype, encoding=None)
Construct an array from a text file, using regular expression parsing. The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to fields of the structured array. Parameters -----...
Construct an array from a text file, using regular expression parsing.
def fromregex(file, regexp, dtype, encoding=None): """ Construct an array from a text file, using regular expression parsing. The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to...
[ "def", "fromregex", "(", "file", ",", "regexp", ",", "dtype", ",", "encoding", "=", "None", ")", ":", "own_fh", "=", "False", "if", "not", "hasattr", "(", "file", ",", "\"read\"", ")", ":", "file", "=", "np", ".", "lib", ".", "_datasource", ".", "o...
[ 1439, 0 ]
[ 1529, 24 ]
python
en
['en', 'error', 'th']
False
genfromtxt
(fname, dtype=float, comments='#', delimiter=None, skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=''.join(sorted(NameValidator.defaultdeletechars)), ...
Load data from a text file, with missing values handled as specified. Each line past the first `skip_header` lines is split at the `delimiter` character, and characters following the `comments` character are discarded. Parameters ---------- fname : file, str, pathlib.Path, list of str, genera...
Load data from a text file, with missing values handled as specified.
def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=''.join(sorted(NameValidator.defaultdeletechars)),...
[ "def", "genfromtxt", "(", "fname", ",", "dtype", "=", "float", ",", "comments", "=", "'#'", ",", "delimiter", "=", "None", ",", "skip_header", "=", "0", ",", "skip_footer", "=", "0", ",", "converters", "=", "None", ",", "missing_values", "=", "None", "...
[ 1538, 0 ]
[ 2230, 27 ]
python
en
['en', 'error', 'th']
False
ndfromtxt
(fname, **kwargs)
Load ASCII data stored in a file and return it as a single array. .. deprecated:: 1.17 ndfromtxt` is a deprecated alias of `genfromtxt` which overwrites the ``usemask`` argument with `False` even when explicitly called as ``ndfromtxt(..., usemask=True)``. Use `genfromtxt` inste...
Load ASCII data stored in a file and return it as a single array.
def ndfromtxt(fname, **kwargs): """ Load ASCII data stored in a file and return it as a single array. .. deprecated:: 1.17 ndfromtxt` is a deprecated alias of `genfromtxt` which overwrites the ``usemask`` argument with `False` even when explicitly called as ``ndfromtxt(..., usemask=...
[ "def", "ndfromtxt", "(", "fname", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'usemask'", "]", "=", "False", "# Numpy 1.17", "warnings", ".", "warn", "(", "\"np.ndfromtxt is a deprecated alias of np.genfromtxt, \"", "\"prefer the latter.\"", ",", "DeprecationWa...
[ 2233, 0 ]
[ 2258, 38 ]
python
en
['en', 'error', 'th']
False
mafromtxt
(fname, **kwargs)
Load ASCII data stored in a text file and return a masked array. .. deprecated:: 1.17 np.mafromtxt is a deprecated alias of `genfromtxt` which overwrites the ``usemask`` argument with `True` even when explicitly called as ``mafromtxt(..., usemask=False)``. Use `genfromtxt` inst...
Load ASCII data stored in a text file and return a masked array.
def mafromtxt(fname, **kwargs): """ Load ASCII data stored in a text file and return a masked array. .. deprecated:: 1.17 np.mafromtxt is a deprecated alias of `genfromtxt` which overwrites the ``usemask`` argument with `True` even when explicitly called as ``mafromtxt(..., usemask=...
[ "def", "mafromtxt", "(", "fname", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'usemask'", "]", "=", "True", "# Numpy 1.17", "warnings", ".", "warn", "(", "\"np.mafromtxt is a deprecated alias of np.genfromtxt, \"", "\"prefer the latter.\"", ",", "DeprecationWar...
[ 2261, 0 ]
[ 2286, 38 ]
python
en
['en', 'error', 'th']
False
recfromtxt
(fname, **kwargs)
Load ASCII data from a file and return it in a record array. If ``usemask=False`` a standard `recarray` is returned, if ``usemask=True`` a MaskedRecords array is returned. Parameters ---------- fname, kwargs : For a description of input parameters, see `genfromtxt`. See Also --------...
Load ASCII data from a file and return it in a record array.
def recfromtxt(fname, **kwargs): """ Load ASCII data from a file and return it in a record array. If ``usemask=False`` a standard `recarray` is returned, if ``usemask=True`` a MaskedRecords array is returned. Parameters ---------- fname, kwargs : For a description of input parameters, see ...
[ "def", "recfromtxt", "(", "fname", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"dtype\"", ",", "None", ")", "usemask", "=", "kwargs", ".", "get", "(", "'usemask'", ",", "False", ")", "output", "=", "genfromtxt", "(", "fname",...
[ 2289, 0 ]
[ 2318, 17 ]
python
en
['en', 'error', 'th']
False
recfromcsv
(fname, **kwargs)
Load ASCII data stored in a comma-separated file. The returned array is a record array (if ``usemask=False``, see `recarray`) or a masked record array (if ``usemask=True``, see `ma.mrecords.MaskedRecords`). Parameters ---------- fname, kwargs : For a description of input parameters, see `...
Load ASCII data stored in a comma-separated file.
def recfromcsv(fname, **kwargs): """ Load ASCII data stored in a comma-separated file. The returned array is a record array (if ``usemask=False``, see `recarray`) or a masked record array (if ``usemask=True``, see `ma.mrecords.MaskedRecords`). Parameters ---------- fname, kwargs : For ...
[ "def", "recfromcsv", "(", "fname", ",", "*", "*", "kwargs", ")", ":", "# Set default kwargs for genfromtxt as relevant to csv import.", "kwargs", ".", "setdefault", "(", "\"case_sensitive\"", ",", "\"lower\"", ")", "kwargs", ".", "setdefault", "(", "\"names\"", ",", ...
[ 2321, 0 ]
[ 2356, 17 ]
python
en
['en', 'error', 'th']
False
BagObj.__dir__
(self)
Enables dir(bagobj) to list the files in an NpzFile. This also enables tab-completion in an interpreter or IPython.
Enables dir(bagobj) to list the files in an NpzFile.
def __dir__(self): """ Enables dir(bagobj) to list the files in an NpzFile. This also enables tab-completion in an interpreter or IPython. """ return list(object.__getattribute__(self, '_obj').keys())
[ "def", "__dir__", "(", "self", ")", ":", "return", "list", "(", "object", ".", "__getattribute__", "(", "self", ",", "'_obj'", ")", ".", "keys", "(", ")", ")" ]
[ 90, 4 ]
[ 96, 65 ]
python
en
['en', 'error', 'th']
False
NpzFile.close
(self)
Close the file.
Close the file.
def close(self): """ Close the file. """ if self.zip is not None: self.zip.close() self.zip = None if self.fid is not None: self.fid.close() self.fid = None self.f = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "zip", "is", "not", "None", ":", "self", ".", "zip", ".", "close", "(", ")", "self", ".", "zip", "=", "None", "if", "self", ".", "fid", "is", "not", "None", ":", "self", ".", "fid", "....
[ 208, 4 ]
[ 219, 21 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Add binary sensors for a config entry.
Add binary sensors for a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Add binary sensors for a config entry.""" broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id] sensors = [] for device in broker.devices.values(): for capability in broker.get_assigned(device.device_id, "sensor"):...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "broker", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BROKERS", "]", "[", "config_entry", ".", "entry_id", "]", "sensors", "=", "[", "]...
[ 402, 0 ]
[ 455, 31 ]
python
en
['en', 'en', 'en']
True
get_capabilities
(capabilities: Sequence[str])
Return all capabilities supported if minimum required are present.
Return all capabilities supported if minimum required are present.
def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None: """Return all capabilities supported if minimum required are present.""" return [ capability for capability in CAPABILITY_TO_SENSORS if capability in capabilities ]
[ "def", "get_capabilities", "(", "capabilities", ":", "Sequence", "[", "str", "]", ")", "->", "Sequence", "[", "str", "]", "|", "None", ":", "return", "[", "capability", "for", "capability", "in", "CAPABILITY_TO_SENSORS", "if", "capability", "in", "capabilities...
[ 458, 0 ]
[ 462, 5 ]
python
en
['en', 'en', 'en']
True
SmartThingsSensor.__init__
( self, device: DeviceEntity, attribute: str, name: str, default_unit: str, device_class: str, state_class: str | None, )
Init the class.
Init the class.
def __init__( self, device: DeviceEntity, attribute: str, name: str, default_unit: str, device_class: str, state_class: str | None, ) -> None: """Init the class.""" super().__init__(device) self._attribute = attribute self._name...
[ "def", "__init__", "(", "self", ",", "device", ":", "DeviceEntity", ",", "attribute", ":", "str", ",", "name", ":", "str", ",", "default_unit", ":", "str", ",", "device_class", ":", "str", ",", "state_class", ":", "str", "|", "None", ",", ")", "->", ...
[ 468, 4 ]
[ 483, 44 ]
python
en
['en', 'en', 'en']
True
SmartThingsSensor.name
(self)
Return the name of the binary sensor.
Return the name of the binary sensor.
def name(self) -> str: """Return the name of the binary sensor.""" return f"{self._device.label} {self._name}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.label} {self._name}\"" ]
[ 486, 4 ]
[ 488, 51 ]
python
en
['en', 'mi', 'en']
True
SmartThingsSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return f"{self._device.device_id}.{self._attribute}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.device_id}.{self._attribute}\"" ]
[ 491, 4 ]
[ 493, 60 ]
python
ca
['fr', 'ca', 'en']
False
SmartThingsSensor.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._device.status.attributes[self._attribute].value
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "status", ".", "attributes", "[", "self", ".", "_attribute", "]", ".", "value" ]
[ 496, 4 ]
[ 498, 68 ]
python
en
['en', 'en', 'en']
True
SmartThingsSensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 501, 4 ]
[ 503, 33 ]
python
en
['en', 'en', 'en']
True
SmartThingsSensor.native_unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" unit = self._device.status.attributes[self._attribute].unit return UNITS.get(unit, unit) if unit else self._default_unit
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "unit", "=", "self", ".", "_device", ".", "status", ".", "attributes", "[", "self", ".", "_attribute", "]", ".", "unit", "return", "UNITS", ".", "get", "(", "unit", ",", "unit", ")", "if", "un...
[ 506, 4 ]
[ 509, 68 ]
python
en
['en', 'en', 'en']
True
SmartThingsThreeAxisSensor.__init__
(self, device, index)
Init the class.
Init the class.
def __init__(self, device, index): """Init the class.""" super().__init__(device) self._index = index
[ "def", "__init__", "(", "self", ",", "device", ",", "index", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ")", "self", ".", "_index", "=", "index" ]
[ 515, 4 ]
[ 518, 27 ]
python
en
['en', 'en', 'en']
True
SmartThingsThreeAxisSensor.name
(self)
Return the name of the binary sensor.
Return the name of the binary sensor.
def name(self) -> str: """Return the name of the binary sensor.""" return f"{self._device.label} {THREE_AXIS_NAMES[self._index]}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.label} {THREE_AXIS_NAMES[self._index]}\"" ]
[ 521, 4 ]
[ 523, 70 ]
python
en
['en', 'mi', 'en']
True
SmartThingsThreeAxisSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return f"{self._device.device_id}.{THREE_AXIS_NAMES[self._index]}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.device_id}.{THREE_AXIS_NAMES[self._index]}\"" ]
[ 526, 4 ]
[ 528, 74 ]
python
ca
['fr', 'ca', 'en']
False
SmartThingsThreeAxisSensor.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.""" three_axis = self._device.status.attributes[Attribute.three_axis].value try: return three_axis[self._index] except (TypeError, IndexError): return None
[ "def", "native_value", "(", "self", ")", ":", "three_axis", "=", "self", ".", "_device", ".", "status", ".", "attributes", "[", "Attribute", ".", "three_axis", "]", ".", "value", "try", ":", "return", "three_axis", "[", "self", ".", "_index", "]", "excep...
[ 531, 4 ]
[ 537, 23 ]
python
en
['en', 'en', 'en']
True
SmartThingsPowerConsumptionSensor.__init__
( self, device: DeviceEntity, report_name: str, )
Init the class.
Init the class.
def __init__( self, device: DeviceEntity, report_name: str, ) -> None: """Init the class.""" super().__init__(device) self.report_name = report_name self._attr_state_class = STATE_CLASS_MEASUREMENT if self.report_name != "power": self._attr...
[ "def", "__init__", "(", "self", ",", "device", ":", "DeviceEntity", ",", "report_name", ":", "str", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "device", ")", "self", ".", "report_name", "=", "report_name", "self", ".", "_attr...
[ 543, 4 ]
[ 553, 65 ]
python
en
['en', 'en', 'en']
True
SmartThingsPowerConsumptionSensor.name
(self)
Return the name of the binary sensor.
Return the name of the binary sensor.
def name(self) -> str: """Return the name of the binary sensor.""" return f"{self._device.label} {self.report_name}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.label} {self.report_name}\"" ]
[ 556, 4 ]
[ 558, 57 ]
python
en
['en', 'mi', 'en']
True
SmartThingsPowerConsumptionSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return f"{self._device.device_id}.{self.report_name}_meter"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.device_id}.{self.report_name}_meter\"" ]
[ 561, 4 ]
[ 563, 67 ]
python
ca
['fr', 'ca', 'en']
False
SmartThingsPowerConsumptionSensor.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.""" value = self._device.status.attributes[Attribute.power_consumption].value if value is None or value.get(self.report_name) is None: return None if self.report_name == "power": return value[self.report_na...
[ "def", "native_value", "(", "self", ")", ":", "value", "=", "self", ".", "_device", ".", "status", ".", "attributes", "[", "Attribute", ".", "power_consumption", "]", ".", "value", "if", "value", "is", "None", "or", "value", ".", "get", "(", "self", "....
[ 566, 4 ]
[ 573, 45 ]
python
en
['en', 'en', 'en']
True
SmartThingsPowerConsumptionSensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" if self.report_name == "power": return DEVICE_CLASS_POWER return DEVICE_CLASS_ENERGY
[ "def", "device_class", "(", "self", ")", ":", "if", "self", ".", "report_name", "==", "\"power\"", ":", "return", "DEVICE_CLASS_POWER", "return", "DEVICE_CLASS_ENERGY" ]
[ 576, 4 ]
[ 580, 34 ]
python
en
['en', 'en', 'en']
True
SmartThingsPowerConsumptionSensor.native_unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" if self.report_name == "power": return POWER_WATT return ENERGY_KILO_WATT_HOUR
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "report_name", "==", "\"power\"", ":", "return", "POWER_WATT", "return", "ENERGY_KILO_WATT_HOUR" ]
[ 583, 4 ]
[ 587, 36 ]
python
en
['en', 'en', 'en']
True
get_host_platform
()
Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included...
Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included...
def get_host_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although th...
[ "def", "get_host_platform", "(", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "if", "'amd64'", "in", "sys", ".", "version", ".", "lower", "(", ")", ":", "return", "'win-amd64'", "if", "'(arm)'", "in", "sys", ".", "version", ".", "lower", "("...
[ 19, 0 ]
[ 97, 50 ]
python
en
['en', 'en', 'en']
True
convert_path
(pathname)
Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can ...
Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can ...
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the...
[ "def", "convert_path", "(", "pathname", ")", ":", "if", "os", ".", "sep", "==", "'/'", ":", "return", "pathname", "if", "not", "pathname", ":", "return", "pathname", "if", "pathname", "[", "0", "]", "==", "'/'", ":", "raise", "ValueError", "(", "\"path...
[ 110, 0 ]
[ 133, 31 ]
python
en
['en', 'en', 'en']
True
change_root
(new_root, pathname)
Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.
Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ if...
[ "def", "change_root", "(", "new_root", ",", "pathname", ")", ":", "if", "os", ".", "name", "==", "'posix'", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "pathname", ")", ":", "return", "os", ".", "path", ".", "join", "(", "new_root", ","...
[ 138, 0 ]
[ 157, 83 ]
python
en
['en', 'en', 'en']
True
check_environ
()
Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platf...
Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platf...
def check_environ (): """Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware ...
[ "def", "check_environ", "(", ")", ":", "global", "_environ_checked", "if", "_environ_checked", ":", "return", "if", "os", ".", "name", "==", "'posix'", "and", "'HOME'", "not", "in", "os", ".", "environ", ":", "try", ":", "import", "pwd", "os", ".", "envi...
[ 161, 0 ]
[ 185, 24 ]
python
en
['en', 'en', 'en']
True
subst_vars
(s, local_vars)
Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guar...
Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guar...
def subst_vars (s, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.envi...
[ "def", "subst_vars", "(", "s", ",", "local_vars", ")", ":", "check_environ", "(", ")", "def", "_subst", "(", "match", ",", "local_vars", "=", "local_vars", ")", ":", "var_name", "=", "match", ".", "group", "(", "1", ")", "if", "var_name", "in", "local_...
[ 188, 0 ]
[ 208, 56 ]
python
en
['en', 'en', 'en']
True
split_quoted
(s)
Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The b...
Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The b...
def split_quoted (s): """Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can ...
[ "def", "split_quoted", "(", "s", ")", ":", "# This is a nice algorithm for splitting up a single string, since it", "# doesn't require character-by-character examination. It was a little", "# bit of a brain-bender to get it working right, though...", "if", "_wordchars_re", "is", "None", "...
[ 228, 0 ]
[ 284, 16 ]
python
en
['en', 'en', 'en']
True
execute
(func, args, msg=None, verbose=0, dry_run=0)
Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to e...
Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to e...
def execute (func, args, msg=None, verbose=0, dry_run=0): """Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is s...
[ "def", "execute", "(", "func", ",", "args", ",", "msg", "=", "None", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ")", ":", "if", "msg", "is", "None", ":", "msg", "=", "\"%s%r\"", "%", "(", "func", ".", "__name__", ",", "args", ")", "if"...
[ 289, 0 ]
[ 305, 19 ]
python
en
['en', 'en', 'en']
True
strtobool
(val)
Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else.
Convert a string representation of truth to true (1) or false (0).
def strtobool (val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. """ val = val.lower() if val in ('y', 'y...
[ "def", "strtobool", "(", "val", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "val", "in", "(", "'y'", ",", "'yes'", ",", "'t'", ",", "'true'", ",", "'on'", ",", "'1'", ")", ":", "return", "1", "elif", "val", "in", "(", "'n'", ",...
[ 308, 0 ]
[ 321, 59 ]
python
en
['en', 'pt', 'en']
True
byte_compile
(py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None)
Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O")...
Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O")...
def byte_compile (py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None): """Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of f...
[ "def", "byte_compile", "(", "py_files", ",", "optimize", "=", "0", ",", "force", "=", "0", ",", "prefix", "=", "None", ",", "base_dir", "=", "None", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ",", "direct", "=", "None", ")", ":", "# Late i...
[ 324, 0 ]
[ 469, 47 ]
python
en
['en', 'en', 'en']
True
rfc822_escape
(header)
Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline.
Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline.
def rfc822_escape (header): """Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. """ lines = header.split('\n') sep = '\n' + 8 * ' ' return sep.join(lines)
[ "def", "rfc822_escape", "(", "header", ")", ":", "lines", "=", "header", ".", "split", "(", "'\\n'", ")", "sep", "=", "'\\n'", "+", "8", "*", "' '", "return", "sep", ".", "join", "(", "lines", ")" ]
[ 473, 0 ]
[ 479, 26 ]
python
en
['en', 'en', 'en']
True
run_2to3
(files, fixer_names=None, options=None, explicit=None)
Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.
Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.
def run_2to3(files, fixer_names=None, options=None, explicit=None): """Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed...
[ "def", "run_2to3", "(", "files", ",", "fixer_names", "=", "None", ",", "options", "=", "None", ",", "explicit", "=", "None", ")", ":", "if", "not", "files", ":", "return", "# Make this class local, to delay import of 2to3", "from", "lib2to3", ".", "refactor", ...
[ 483, 0 ]
[ 508, 33 ]
python
en
['en', 'haw', 'en']
True
copydir_run_2to3
(src, dest, template=None, fixer_names=None, options=None, explicit=None)
Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in.
Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward.
def copydir_run_2to3(src, dest, template=None, fixer_names=None, options=None, explicit=None): """Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFES...
[ "def", "copydir_run_2to3", "(", "src", ",", "dest", ",", "template", "=", "None", ",", "fixer_names", "=", "None", ",", "options", "=", "None", ",", "explicit", "=", "None", ")", ":", "from", "distutils", ".", "dir_util", "import", "mkpath", "from", "dis...
[ 510, 0 ]
[ 541, 17 ]
python
en
['en', 'en', 'en']
True
test_override_single_value
()
Test values with exact match.
Test values with exact match.
def test_override_single_value(): """Test values with exact match.""" store = EV({ent: {"key": "value"}}) assert store.get(ent) == {"key": "value"} assert len(store._cache) == 1 assert store.get(ent) == {"key": "value"} assert len(store._cache) == 1
[ "def", "test_override_single_value", "(", ")", ":", "store", "=", "EV", "(", "{", "ent", ":", "{", "\"key\"", ":", "\"value\"", "}", "}", ")", "assert", "store", ".", "get", "(", "ent", ")", "==", "{", "\"key\"", ":", "\"value\"", "}", "assert", "len...
[ 8, 0 ]
[ 14, 33 ]
python
en
['en', 'en', 'en']
True
test_override_by_domain
()
Test values with domain match.
Test values with domain match.
def test_override_by_domain(): """Test values with domain match.""" store = EV(domain={"test": {"key": "value"}}) assert store.get(ent) == {"key": "value"}
[ "def", "test_override_by_domain", "(", ")", ":", "store", "=", "EV", "(", "domain", "=", "{", "\"test\"", ":", "{", "\"key\"", ":", "\"value\"", "}", "}", ")", "assert", "store", ".", "get", "(", "ent", ")", "==", "{", "\"key\"", ":", "\"value\"", "}...
[ 17, 0 ]
[ 20, 45 ]
python
en
['en', 'en', 'en']
True
test_override_by_glob
()
Test values with glob match.
Test values with glob match.
def test_override_by_glob(): """Test values with glob match.""" store = EV(glob={"test.?e*": {"key": "value"}}) assert store.get(ent) == {"key": "value"}
[ "def", "test_override_by_glob", "(", ")", ":", "store", "=", "EV", "(", "glob", "=", "{", "\"test.?e*\"", ":", "{", "\"key\"", ":", "\"value\"", "}", "}", ")", "assert", "store", ".", "get", "(", "ent", ")", "==", "{", "\"key\"", ":", "\"value\"", "}...
[ 23, 0 ]
[ 26, 45 ]
python
en
['en', 'en', 'en']
True
test_glob_overrules_domain
()
Test domain overrules glob match.
Test domain overrules glob match.
def test_glob_overrules_domain(): """Test domain overrules glob match.""" store = EV(domain={"test": {"key": "domain"}}, glob={"test.?e*": {"key": "glob"}}) assert store.get(ent) == {"key": "glob"}
[ "def", "test_glob_overrules_domain", "(", ")", ":", "store", "=", "EV", "(", "domain", "=", "{", "\"test\"", ":", "{", "\"key\"", ":", "\"domain\"", "}", "}", ",", "glob", "=", "{", "\"test.?e*\"", ":", "{", "\"key\"", ":", "\"glob\"", "}", "}", ")", ...
[ 29, 0 ]
[ 32, 44 ]
python
en
['en', 'bg', 'en']
True
test_exact_overrules_domain
()
Test exact overrules domain match.
Test exact overrules domain match.
def test_exact_overrules_domain(): """Test exact overrules domain match.""" store = EV( exact={"test.test": {"key": "exact"}}, domain={"test": {"key": "domain"}}, glob={"test.?e*": {"key": "glob"}}, ) assert store.get(ent) == {"key": "exact"}
[ "def", "test_exact_overrules_domain", "(", ")", ":", "store", "=", "EV", "(", "exact", "=", "{", "\"test.test\"", ":", "{", "\"key\"", ":", "\"exact\"", "}", "}", ",", "domain", "=", "{", "\"test\"", ":", "{", "\"key\"", ":", "\"domain\"", "}", "}", ",...
[ 35, 0 ]
[ 42, 45 ]
python
en
['fr', 'en', 'en']
True
test_merging_values
()
Test merging glob, domain and exact configs.
Test merging glob, domain and exact configs.
def test_merging_values(): """Test merging glob, domain and exact configs.""" store = EV( exact={"test.test": {"exact_key": "exact"}}, domain={"test": {"domain_key": "domain"}}, glob={"test.?e*": {"glob_key": "glob"}}, ) assert store.get(ent) == { "exact_key": "exact", ...
[ "def", "test_merging_values", "(", ")", ":", "store", "=", "EV", "(", "exact", "=", "{", "\"test.test\"", ":", "{", "\"exact_key\"", ":", "\"exact\"", "}", "}", ",", "domain", "=", "{", "\"test\"", ":", "{", "\"domain_key\"", ":", "\"domain\"", "}", "}",...
[ 45, 0 ]
[ 56, 5 ]
python
en
['en', 'en', 'en']
True
test_glob_order
()
Test merging glob, domain and exact configs.
Test merging glob, domain and exact configs.
def test_glob_order(): """Test merging glob, domain and exact configs.""" glob = OrderedDict() glob["test.*est"] = {"value": "first"} glob["test.*"] = {"value": "second"} store = EV(glob=glob) assert store.get(ent) == {"value": "second"}
[ "def", "test_glob_order", "(", ")", ":", "glob", "=", "OrderedDict", "(", ")", "glob", "[", "\"test.*est\"", "]", "=", "{", "\"value\"", ":", "\"first\"", "}", "glob", "[", "\"test.*\"", "]", "=", "{", "\"value\"", ":", "\"second\"", "}", "store", "=", ...
[ 59, 0 ]
[ 66, 48 ]
python
en
['en', 'en', 'en']
True
_check_mode
(mode, encoding, newline)
Check mode and that encoding and newline are compatible. Parameters ---------- mode : str File open mode. encoding : str File encoding. newline : str Newline for text files.
Check mode and that encoding and newline are compatible.
def _check_mode(mode, encoding, newline): """Check mode and that encoding and newline are compatible. Parameters ---------- mode : str File open mode. encoding : str File encoding. newline : str Newline for text files. """ if "t" in mode: if "b" in mode:...
[ "def", "_check_mode", "(", "mode", ",", "encoding", ",", "newline", ")", ":", "if", "\"t\"", "in", "mode", ":", "if", "\"b\"", "in", "mode", ":", "raise", "ValueError", "(", "\"Invalid mode: %r\"", "%", "(", "mode", ",", ")", ")", "else", ":", "if", ...
[ 47, 0 ]
[ 67, 79 ]
python
en
['en', 'en', 'en']
True
open
(path, mode='r', destpath=os.curdir, encoding=None, newline=None)
Open `path` with `mode` and return the file object. If ``path`` is an URL, it will be downloaded, stored in the `DataSource` `destpath` directory and opened from there. Parameters ---------- path : str Local file path or URL to open. mode : str, optional Mode to open `path...
Open `path` with `mode` and return the file object.
def open(path, mode='r', destpath=os.curdir, encoding=None, newline=None): """ Open `path` with `mode` and return the file object. If ``path`` is an URL, it will be downloaded, stored in the `DataSource` `destpath` directory and opened from there. Parameters ---------- path : str L...
[ "def", "open", "(", "path", ",", "mode", "=", "'r'", ",", "destpath", "=", "os", ".", "curdir", ",", "encoding", "=", "None", ",", "newline", "=", "None", ")", ":", "ds", "=", "DataSource", "(", "destpath", ")", "return", "ds", ".", "open", "(", ...
[ 156, 0 ]
[ 194, 66 ]
python
en
['en', 'error', 'th']
False
_FileOpeners.keys
(self)
Return the keys of currently supported file openers. Parameters ---------- None Returns ------- keys : list The keys are None for uncompressed files and the file extension strings (i.e. ``'.gz'``, ``'.xz'``) for supported compression ...
Return the keys of currently supported file openers.
def keys(self): """ Return the keys of currently supported file openers. Parameters ---------- None Returns ------- keys : list The keys are None for uncompressed files and the file extension strings (i.e. ``'.gz'``, ``'.xz'``) fo...
[ "def", "keys", "(", "self", ")", ":", "self", ".", "_load", "(", ")", "return", "list", "(", "self", ".", "_file_openers", ".", "keys", "(", ")", ")" ]
[ 131, 4 ]
[ 148, 46 ]
python
en
['en', 'error', 'th']
False
Repository.__init__
(self, baseurl, destpath=os.curdir)
Create a Repository with a shared url or directory of baseurl.
Create a Repository with a shared url or directory of baseurl.
def __init__(self, baseurl, destpath=os.curdir): """Create a Repository with a shared url or directory of baseurl.""" DataSource.__init__(self, destpath=destpath) self._baseurl = baseurl
[ "def", "__init__", "(", "self", ",", "baseurl", ",", "destpath", "=", "os", ".", "curdir", ")", ":", "DataSource", ".", "__init__", "(", "self", ",", "destpath", "=", "destpath", ")", "self", ".", "_baseurl", "=", "baseurl" ]
[ 577, 4 ]
[ 580, 31 ]
python
en
['en', 'en', 'en']
True
Repository._fullpath
(self, path)
Return complete path for path. Prepends baseurl if necessary.
Return complete path for path. Prepends baseurl if necessary.
def _fullpath(self, path): """Return complete path for path. Prepends baseurl if necessary.""" splitpath = path.split(self._baseurl, 2) if len(splitpath) == 1: result = os.path.join(self._baseurl, path) else: result = path # path contains baseurl already ...
[ "def", "_fullpath", "(", "self", ",", "path", ")", ":", "splitpath", "=", "path", ".", "split", "(", "self", ".", "_baseurl", ",", "2", ")", "if", "len", "(", "splitpath", ")", "==", "1", ":", "result", "=", "os", ".", "path", ".", "join", "(", ...
[ 585, 4 ]
[ 592, 21 ]
python
en
['en', 'en', 'en']
True
Repository._findfile
(self, path)
Extend DataSource method to prepend baseurl to ``path``.
Extend DataSource method to prepend baseurl to ``path``.
def _findfile(self, path): """Extend DataSource method to prepend baseurl to ``path``.""" return DataSource._findfile(self, self._fullpath(path))
[ "def", "_findfile", "(", "self", ",", "path", ")", ":", "return", "DataSource", ".", "_findfile", "(", "self", ",", "self", ".", "_fullpath", "(", "path", ")", ")" ]
[ 594, 4 ]
[ 596, 63 ]
python
en
['en', 'en', 'en']
True
Repository.abspath
(self, path)
Return absolute path of file in the Repository directory. If `path` is an URL, then `abspath` will return either the location the file exists locally or the location it would exist when opened using the `open` method. Parameters ---------- path : str ...
Return absolute path of file in the Repository directory.
def abspath(self, path): """ Return absolute path of file in the Repository directory. If `path` is an URL, then `abspath` will return either the location the file exists locally or the location it would exist when opened using the `open` method. Parameters ----...
[ "def", "abspath", "(", "self", ",", "path", ")", ":", "return", "DataSource", ".", "abspath", "(", "self", ",", "self", ".", "_fullpath", "(", "path", ")", ")" ]
[ 598, 4 ]
[ 619, 61 ]
python
en
['en', 'error', 'th']
False
Repository.exists
(self, path)
Test if path exists prepending Repository base URL to path. Test if `path` exists as (and in this order): - a local file. - a remote URL that has been downloaded and stored locally in the `DataSource` directory. - a remote URL that has not been downloaded, but is val...
Test if path exists prepending Repository base URL to path.
def exists(self, path): """ Test if path exists prepending Repository base URL to path. Test if `path` exists as (and in this order): - a local file. - a remote URL that has been downloaded and stored locally in the `DataSource` directory. - a remote URL that ...
[ "def", "exists", "(", "self", ",", "path", ")", ":", "return", "DataSource", ".", "exists", "(", "self", ",", "self", ".", "_fullpath", "(", "path", ")", ")" ]
[ 621, 4 ]
[ 653, 60 ]
python
en
['en', 'error', 'th']
False
Repository.open
(self, path, mode='r', encoding=None, newline=None)
Open and return file-like object prepending Repository base URL. If `path` is an URL, it will be downloaded, stored in the DataSource directory and opened from there. Parameters ---------- path : str Local file path or URL to open. This may, but does not ha...
Open and return file-like object prepending Repository base URL.
def open(self, path, mode='r', encoding=None, newline=None): """ Open and return file-like object prepending Repository base URL. If `path` is an URL, it will be downloaded, stored in the DataSource directory and opened from there. Parameters ---------- path : s...
[ "def", "open", "(", "self", ",", "path", ",", "mode", "=", "'r'", ",", "encoding", "=", "None", ",", "newline", "=", "None", ")", ":", "return", "DataSource", ".", "open", "(", "self", ",", "self", ".", "_fullpath", "(", "path", ")", ",", "mode", ...
[ 655, 4 ]
[ 685, 66 ]
python
en
['en', 'error', 'th']
False
Repository.listdir
(self)
List files in the source Repository. Returns ------- files : list of str List of file names (not containing a directory part). Notes ----- Does not currently work for remote repositories.
List files in the source Repository.
def listdir(self): """ List files in the source Repository. Returns ------- files : list of str List of file names (not containing a directory part). Notes ----- Does not currently work for remote repositories. """ if self._i...
[ "def", "listdir", "(", "self", ")", ":", "if", "self", ".", "_isurl", "(", "self", ".", "_baseurl", ")", ":", "raise", "NotImplementedError", "(", "\"Directory listing of URLs, not supported yet.\"", ")", "else", ":", "return", "os", ".", "listdir", "(", "self...
[ 687, 4 ]
[ 705, 44 ]
python
en
['en', 'error', 'th']
False
Shape.additional_properties_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
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 additional_properties_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 """ lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,)
[ "def", "additional_properties_type", "(", ")", ":", "lazy_import", "(", ")", "return", "(", "bool", ",", "date", ",", "datetime", ",", "dict", ",", "float", ",", "int", ",", "list", ",", "str", ",", "none_type", ",", ")" ]
[ 66, 4 ]
[ 72, 78 ]
python
en
['en', 'error', 'th']
False
Shape.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. """ lazy...
[ "def", "openapi_types", "(", ")", ":", "lazy_import", "(", ")", "return", "{", "'shape_type'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "'quadrilateral_type'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "'triangle_type'", ":", "(", "str", ",", ...
[ 77, 4 ]
[ 91, 9 ]
python
en
['en', 'error', 'th']
False
Shape.__init__
(self, shape_type, *args, **kwargs)
Shape - a model defined in OpenAPI Args: shape_type (str): 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 ...
Shape - a model defined in OpenAPI
def __init__(self, shape_type, *args, **kwargs): # noqa: E501 """Shape - a model defined in OpenAPI Args: shape_type (str): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a Type...
[ "def", "__init__", "(", "self", ",", "shape_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "pop", ...
[ 123, 4 ]
[ 216, 46 ]
python
en
['en', 'fy', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Vultr subscription (server) binary sensor.
Set up the Vultr subscription (server) binary sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Vultr subscription (server) binary sensor.""" vultr = hass.data[DATA_VULTR] subscription = config.get(CONF_SUBSCRIPTION) name = config.get(CONF_NAME) if subscription not in vultr.data: _LOGGER.error("Subscri...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "vultr", "=", "hass", ".", "data", "[", "DATA_VULTR", "]", "subscription", "=", "config", ".", "get", "(", "CONF_SUBSCRIPTION", ")", "na...
[ 39, 0 ]
[ 50, 70 ]
python
en
['en', 'sv', 'en']
True
VultrBinarySensor.__init__
(self, vultr, subscription, name)
Initialize a new Vultr binary sensor.
Initialize a new Vultr binary sensor.
def __init__(self, vultr, subscription, name): """Initialize a new Vultr binary sensor.""" self._vultr = vultr self._name = name self.subscription = subscription self.data = None
[ "def", "__init__", "(", "self", ",", "vultr", ",", "subscription", ",", "name", ")", ":", "self", ".", "_vultr", "=", "vultr", "self", ".", "_name", "=", "name", "self", ".", "subscription", "=", "subscription", "self", ".", "data", "=", "None" ]
[ 58, 4 ]
[ 64, 24 ]
python
en
['en', 'en', 'en']
True
VultrBinarySensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" try: return self._name.format(self.data["label"]) except (KeyError, TypeError): return self._name
[ "def", "name", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_name", ".", "format", "(", "self", ".", "data", "[", "\"label\"", "]", ")", "except", "(", "KeyError", ",", "TypeError", ")", ":", "return", "self", ".", "_name" ]
[ 67, 4 ]
[ 72, 29 ]
python
en
['en', 'mi', 'en']
True
VultrBinarySensor.icon
(self)
Return the icon of this server.
Return the icon of this server.
def icon(self): """Return the icon of this server.""" return "mdi:server" if self.is_on else "mdi:server-off"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:server\"", "if", "self", ".", "is_on", "else", "\"mdi:server-off\"" ]
[ 75, 4 ]
[ 77, 63 ]
python
en
['en', 'en', 'en']
True
VultrBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self.data["power_status"] == "running"
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "data", "[", "\"power_status\"", "]", "==", "\"running\"" ]
[ 80, 4 ]
[ 82, 53 ]
python
en
['en', 'fy', 'en']
True
VultrBinarySensor.extra_state_attributes
(self)
Return the state attributes of the Vultr subscription.
Return the state attributes of the Vultr subscription.
def extra_state_attributes(self): """Return the state attributes of the Vultr subscription.""" return { ATTR_ALLOWED_BANDWIDTH: self.data.get("allowed_bandwidth_gb"), ATTR_AUTO_BACKUPS: self.data.get("auto_backups"), ATTR_COST_PER_MONTH: self.data.get("cost_per_month"...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ALLOWED_BANDWIDTH", ":", "self", ".", "data", ".", "get", "(", "\"allowed_bandwidth_gb\"", ")", ",", "ATTR_AUTO_BACKUPS", ":", "self", ".", "data", ".", "get", "(", "\"auto_backups\"", ...
[ 85, 4 ]
[ 101, 9 ]
python
en
['en', 'en', 'en']
True
VultrBinarySensor.update
(self)
Update state of sensor.
Update state of sensor.
def update(self): """Update state of sensor.""" self._vultr.update() self.data = self._vultr.data[self.subscription]
[ "def", "update", "(", "self", ")", ":", "self", ".", "_vultr", ".", "update", "(", ")", "self", ".", "data", "=", "self", ".", "_vultr", ".", "data", "[", "self", ".", "subscription", "]" ]
[ 103, 4 ]
[ 106, 55 ]
python
en
['en', 'co', 'en']
True
storage_setup
(hass, hass_storage)
Storage setup.
Storage setup.
def storage_setup(hass, hass_storage): """Storage setup.""" async def _storage(items=None, config=None): if items is None: hass_storage[DOMAIN] = { "key": DOMAIN, "version": 1, "data": { "items": [ {...
[ "def", "storage_setup", "(", "hass", ",", "hass_storage", ")", ":", "async", "def", "_storage", "(", "items", "=", "None", ",", "config", "=", "None", ")", ":", "if", "items", "is", "None", ":", "hass_storage", "[", "DOMAIN", "]", "=", "{", "\"key\"", ...
[ 36, 0 ]
[ 64, 19 ]
python
en
['en', 'bs', 'en']
False
select_option
(hass, entity_id, option)
Set value of input_select. This is a legacy helper method. Do not use it for new tests.
Set value of input_select.
def select_option(hass, entity_id, option): """Set value of input_select. This is a legacy helper method. Do not use it for new tests. """ hass.async_create_task( hass.services.async_call( DOMAIN, SERVICE_SELECT_OPTION, {ATTR_ENTITY_ID: entity_id, ATTR_OPTION...
[ "def", "select_option", "(", "hass", ",", "entity_id", ",", "option", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_OPTION", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", ",", ...
[ 68, 0 ]
[ 79, 5 ]
python
en
['en', 'en', 'en']
True
select_next
(hass, entity_id)
Set next value of input_select. This is a legacy helper method. Do not use it for new tests.
Set next value of input_select.
def select_next(hass, entity_id): """Set next value of input_select. This is a legacy helper method. Do not use it for new tests. """ hass.async_create_task( hass.services.async_call( DOMAIN, SERVICE_SELECT_NEXT, {ATTR_ENTITY_ID: entity_id} ) )
[ "def", "select_next", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_NEXT", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 83, 0 ]
[ 92, 5 ]
python
en
['en', 'su', 'en']
True
select_previous
(hass, entity_id)
Set previous value of input_select. This is a legacy helper method. Do not use it for new tests.
Set previous value of input_select.
def select_previous(hass, entity_id): """Set previous value of input_select. This is a legacy helper method. Do not use it for new tests. """ hass.async_create_task( hass.services.async_call( DOMAIN, SERVICE_SELECT_PREVIOUS, {ATTR_ENTITY_ID: entity_id} ) )
[ "def", "select_previous", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_PREVIOUS", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 96, 0 ]
[ 105, 5 ]
python
en
['en', 'en', 'en']
True
select_first
(hass, entity_id)
Set first value of input_select. This is a legacy helper method. Do not use it for new tests.
Set first value of input_select.
def select_first(hass, entity_id): """Set first value of input_select. This is a legacy helper method. Do not use it for new tests. """ hass.async_create_task( hass.services.async_call( DOMAIN, SERVICE_SELECT_FIRST, {ATTR_ENTITY_ID: entity_id} ) )
[ "def", "select_first", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_FIRST", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 109, 0 ]
[ 118, 5 ]
python
en
['en', 'en', 'en']
True
select_last
(hass, entity_id)
Set last value of input_select. This is a legacy helper method. Do not use it for new tests.
Set last value of input_select.
def select_last(hass, entity_id): """Set last value of input_select. This is a legacy helper method. Do not use it for new tests. """ hass.async_create_task( hass.services.async_call( DOMAIN, SERVICE_SELECT_LAST, {ATTR_ENTITY_ID: entity_id} ) )
[ "def", "select_last", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_LAST", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 122, 0 ]
[ 131, 5 ]
python
en
['en', 'en', 'en']
True
test_config
(hass)
Test config.
Test config.
async def test_config(hass): """Test config.""" invalid_configs = [ None, {}, {"name with space": None}, # {'bad_options': {'options': None}}, {"bad_initial": {"options": [1, 2], "initial": 3}}, ] for cfg in invalid_configs: assert not await async_setup_c...
[ "async", "def", "test_config", "(", "hass", ")", ":", "invalid_configs", "=", "[", "None", ",", "{", "}", ",", "{", "\"name with space\"", ":", "None", "}", ",", "# {'bad_options': {'options': None}},", "{", "\"bad_initial\"", ":", "{", "\"options\"", ":", "["...
[ 134, 0 ]
[ 145, 75 ]
python
en
['en', 'en', 'en']
False
test_select_option
(hass)
Test select_option methods.
Test select_option methods.
async def test_select_option(hass): """Test select_option methods.""" assert await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_1": {"options": ["some option", "another option"]}}}, ) entity_id = "input_select.test_1" state = hass.states.get(entity_id) assert sta...
[ "async", "def", "test_select_option", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_1\"", ":", "{", "\"options\"", ":", "[", "\"some option\"", ",", "\"another option\"", "]...
[ 148, 0 ]
[ 170, 42 ]
python
en
['en', 'en', 'en']
True
test_select_next
(hass)
Test select_next methods.
Test select_next methods.
async def test_select_next(hass): """Test select_next methods.""" assert await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_1": { "options": ["first option", "middle option", "last option"], "initial": "middle ...
[ "async", "def", "test_select_next", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_1\"", ":", "{", "\"options\"", ":", "[", "\"first option\"", ",", "\"middle option\"", ",",...
[ 173, 0 ]
[ 202, 40 ]
python
en
['en', 'en', 'en']
True
test_select_previous
(hass)
Test select_previous methods.
Test select_previous methods.
async def test_select_previous(hass): """Test select_previous methods.""" assert await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_1": { "options": ["first option", "middle option", "last option"], "initial": ...
[ "async", "def", "test_select_previous", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_1\"", ":", "{", "\"options\"", ":", "[", "\"first option\"", ",", "\"middle option\"", ...
[ 205, 0 ]
[ 234, 39 ]
python
en
['en', 'en', 'en']
True
test_select_first_last
(hass)
Test select_first and _last methods.
Test select_first and _last methods.
async def test_select_first_last(hass): """Test select_first and _last methods.""" assert await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_1": { "options": ["first option", "middle option", "last option"], "i...
[ "async", "def", "test_select_first_last", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_1\"", ":", "{", "\"options\"", ":", "[", "\"first option\"", ",", "\"middle option\"", ...
[ 237, 0 ]
[ 266, 39 ]
python
en
['en', 'en', 'en']
True
test_config_options
(hass)
Test configuration options.
Test configuration options.
async def test_config_options(hass): """Test configuration options.""" count_start = len(hass.states.async_entity_ids()) test_2_options = ["Good Option", "Better Option", "Best Option"] assert await async_setup_component( hass, DOMAIN, { DOMAIN: { "t...
[ "async", "def", "test_config_options", "(", "hass", ")", ":", "count_start", "=", "len", "(", "hass", ".", "states", ".", "async_entity_ids", "(", ")", ")", "test_2_options", "=", "[", "\"Good Option\"", ",", "\"Better Option\"", ",", "\"Best Option\"", "]", "...
[ 269, 0 ]
[ 306, 58 ]
python
en
['en', 'fr', 'en']
True
test_set_options_service
(hass)
Test set_options service.
Test set_options service.
async def test_set_options_service(hass): """Test set_options service.""" assert await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_1": { "options": ["first option", "middle option", "last option"], "initial": ...
[ "async", "def", "test_set_options_service", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_1\"", ":", "{", "\"options\"", ":", "[", "\"first option\"", ",", "\"middle option\""...
[ 309, 0 ]
[ 343, 33 ]
python
en
['en', 'fr', 'en']
True
test_restore_state
(hass)
Ensure states are restored on startup.
Ensure states are restored on startup.
async def test_restore_state(hass): """Ensure states are restored on startup.""" mock_restore_cache( hass, ( State("input_select.s1", "last option"), State("input_select.s2", "bad option"), ), ) options = {"options": ["first option", "middle option", "las...
[ "async", "def", "test_restore_state", "(", "hass", ")", ":", "mock_restore_cache", "(", "hass", ",", "(", "State", "(", "\"input_select.s1\"", ",", "\"last option\"", ")", ",", "State", "(", "\"input_select.s2\"", ",", "\"bad option\"", ")", ",", ")", ",", ")"...
[ 346, 0 ]
[ 366, 40 ]
python
en
['en', 'en', 'en']
True
test_initial_state_overrules_restore_state
(hass)
Ensure states are restored on startup.
Ensure states are restored on startup.
async def test_initial_state_overrules_restore_state(hass): """Ensure states are restored on startup.""" mock_restore_cache( hass, ( State("input_select.s1", "last option"), State("input_select.s2", "bad option"), ), ) options = { "options": ["fir...
[ "async", "def", "test_initial_state_overrules_restore_state", "(", "hass", ")", ":", "mock_restore_cache", "(", "hass", ",", "(", "State", "(", "\"input_select.s1\"", ",", "\"last option\"", ")", ",", "State", "(", "\"input_select.s2\"", ",", "\"bad option\"", ")", ...
[ 369, 0 ]
[ 392, 41 ]
python
en
['en', 'en', 'en']
True
test_input_select_context
(hass, hass_admin_user)
Test that input_select context works.
Test that input_select context works.
async def test_input_select_context(hass, hass_admin_user): """Test that input_select context works.""" assert await async_setup_component( hass, "input_select", { "input_select": { "s1": {"options": ["first option", "middle option", "last option"]} ...
[ "async", "def", "test_input_select_context", "(", "hass", ",", "hass_admin_user", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"input_select\"", ",", "{", "\"input_select\"", ":", "{", "\"s1\"", ":", "{", "\"options\"", ":", "[", "\"...
[ 395, 0 ]
[ 421, 55 ]
python
en
['en', 'en', 'en']
True