Spelling and grammar fixes (#499)

This commit is contained in:
Ville Skyttä 2018-06-08 22:32:06 +03:00 committed by Pascal Vizeli
parent 41943ba61a
commit e2725f8033
20 changed files with 36 additions and 36 deletions

2
API.md
View File

@ -579,7 +579,7 @@ return:
#### MQTT #### MQTT
This service perform a auto discovery to Home-Assistant. This service performs an auto discovery to Home-Assistant.
- GET `/services/mqtt` - GET `/services/mqtt`
```json ```json

View File

@ -40,11 +40,11 @@ class AddonManager(CoreSysAttributes):
return list(self.repositories_obj.values()) return list(self.repositories_obj.values())
def get(self, addon_slug): def get(self, addon_slug):
"""Return a add-on from slug.""" """Return an add-on from slug."""
return self.addons_obj.get(addon_slug) return self.addons_obj.get(addon_slug)
def from_uuid(self, uuid): def from_uuid(self, uuid):
"""Return a add-on from uuid.""" """Return an add-on from uuid."""
for addon in self.list_addons: for addon in self.list_addons:
if addon.is_installed and uuid == addon.uuid: if addon.is_installed and uuid == addon.uuid:
return addon return addon

View File

@ -70,7 +70,7 @@ class Addon(CoreSysAttributes):
@property @property
def is_installed(self): def is_installed(self):
"""Return True if a addon is installed.""" """Return True if an addon is installed."""
return self._id in self._data.system return self._id in self._data.system
@property @property
@ -164,7 +164,7 @@ class Addon(CoreSysAttributes):
@property @property
def uuid(self): def uuid(self):
"""Return a API token for this add-on.""" """Return an API token for this add-on."""
if self.is_installed: if self.is_installed:
return self._data.user[self._id][ATTR_UUID] return self._data.user[self._id][ATTR_UUID]
return None return None
@ -411,7 +411,7 @@ class Addon(CoreSysAttributes):
@property @property
def with_icon(self): def with_icon(self):
"""Return True if a icon exists.""" """Return True if an icon exists."""
return self.path_icon.exists() return self.path_icon.exists()
@property @property
@ -589,7 +589,7 @@ class Addon(CoreSysAttributes):
return True return True
async def install(self): async def install(self):
"""Install a addon.""" """Install an addon."""
if self.sys_arch not in self.supported_arch: if self.sys_arch not in self.supported_arch:
_LOGGER.error( _LOGGER.error(
"Addon %s not supported on %s", self._id, self.sys_arch) "Addon %s not supported on %s", self._id, self.sys_arch)
@ -612,7 +612,7 @@ class Addon(CoreSysAttributes):
@check_installed @check_installed
async def uninstall(self): async def uninstall(self):
"""Remove a addon.""" """Remove an addon."""
if not await self.instance.remove(): if not await self.instance.remove():
return False return False
@ -734,7 +734,7 @@ class Addon(CoreSysAttributes):
@check_installed @check_installed
async def snapshot(self, tar_file): async def snapshot(self, tar_file):
"""Snapshot a state of a addon.""" """Snapshot state of an addon."""
with TemporaryDirectory(dir=str(self.sys_config.path_tmp)) as temp: with TemporaryDirectory(dir=str(self.sys_config.path_tmp)) as temp:
# store local image # store local image
if self.need_build and not await \ if self.need_build and not await \
@ -773,7 +773,7 @@ class Addon(CoreSysAttributes):
return True return True
async def restore(self, tar_file): async def restore(self, tar_file):
"""Restore a state of a addon.""" """Restore state of an addon."""
with TemporaryDirectory(dir=str(self.sys_config.path_tmp)) as temp: with TemporaryDirectory(dir=str(self.sys_config.path_tmp)) as temp:
# extract snapshot # extract snapshot
def _extract_tarfile(): def _extract_tarfile():

View File

@ -42,10 +42,10 @@ class APIAddons(CoreSysAttributes):
"""Handle rest api for addons functions.""" """Handle rest api for addons functions."""
def _extract_addon(self, request, check_installed=True): def _extract_addon(self, request, check_installed=True):
"""Return addon and if not exists trow a exception.""" """Return addon, throw an exception it it doesn't exist."""
addon = self.sys_addons.get(request.match_info.get('addon')) addon = self.sys_addons.get(request.match_info.get('addon'))
if not addon: if not addon:
raise RuntimeError("Addon not exists") raise RuntimeError("Addon does not exist")
if check_installed and not addon.is_installed: if check_installed and not addon.is_installed:
raise RuntimeError("Addon is not installed") raise RuntimeError("Addon is not installed")

View File

@ -10,10 +10,10 @@ class APIServices(CoreSysAttributes):
"""Handle rest api for services functions.""" """Handle rest api for services functions."""
def _extract_service(self, request): def _extract_service(self, request):
"""Return service and if not exists trow a exception.""" """Return service, throw an exception if it doesn't exist."""
service = self.sys_services.get(request.match_info.get('service')) service = self.sys_services.get(request.match_info.get('service'))
if not service: if not service:
raise RuntimeError("Service not exists") raise RuntimeError("Service does not exist")
return service return service

View File

@ -49,10 +49,10 @@ class APISnapshots(CoreSysAttributes):
"""Handle rest api for snapshot functions.""" """Handle rest api for snapshot functions."""
def _extract_snapshot(self, request): def _extract_snapshot(self, request):
"""Return addon and if not exists trow a exception.""" """Return snapshot, throw an exception if it doesn't exist."""
snapshot = self.sys_snapshots.get(request.match_info.get('snapshot')) snapshot = self.sys_snapshots.get(request.match_info.get('snapshot'))
if not snapshot: if not snapshot:
raise RuntimeError("Snapshot not exists") raise RuntimeError("Snapshot does not exist")
return snapshot return snapshot
@api_process @api_process

View File

@ -119,7 +119,7 @@ class APISupervisor(CoreSysAttributes):
@api_process @api_process
async def reload(self, request): async def reload(self, request):
"""Reload addons, config ect.""" """Reload addons, config etc."""
tasks = [ tasks = [
self.sys_updater.reload(), self.sys_updater.reload(),
] ]

View File

@ -71,7 +71,7 @@ def api_process_raw(content):
def api_return_error(message=None): def api_return_error(message=None):
"""Return a API error message.""" """Return an API error message."""
return web.json_response({ return web.json_response({
JSON_RESULT: RESULT_ERROR, JSON_RESULT: RESULT_ERROR,
JSON_MESSAGE: message, JSON_MESSAGE: message,
@ -79,7 +79,7 @@ def api_return_error(message=None):
def api_return_ok(data=None): def api_return_ok(data=None):
"""Return a API ok answer.""" """Return an API ok answer."""
return web.json_response({ return web.json_response({
JSON_RESULT: RESULT_OK, JSON_RESULT: RESULT_OK,
JSON_DATA: data or {}, JSON_DATA: data or {},

View File

@ -147,7 +147,7 @@ class CoreSys:
@api.setter @api.setter
def api(self, value): def api(self, value):
"""Set a API object.""" """Set an API object."""
if self._api: if self._api:
raise RuntimeError("API already set!") raise RuntimeError("API already set!")
self._api = value self._api = value

View File

@ -120,7 +120,7 @@ class DockerInterface(CoreSysAttributes):
if container.status != 'running': if container.status != 'running':
return False return False
# we run on a old image, stop and start it # we run on an old image, stop and start it
if container.image.id != image.id: if container.image.id != image.id:
return False return False

View File

@ -116,7 +116,7 @@ class AlsaAudio(CoreSysAttributes):
return self._default return self._default
def asound(self, alsa_input=None, alsa_output=None): def asound(self, alsa_input=None, alsa_output=None):
"""Generate a asound data.""" """Generate an asound data."""
alsa_input = alsa_input or self.default.input alsa_input = alsa_input or self.default.input
alsa_output = alsa_output or self.default.output alsa_output = alsa_output or self.default.output

View File

@ -24,7 +24,7 @@ RE_TTY = re.compile(r"tty[A-Z]+")
class Hardware: class Hardware:
"""Represent a interface to procfs, sysfs and udev.""" """Represent an interface to procfs, sysfs and udev."""
def __init__(self): def __init__(self):
"""Init hardware object.""" """Init hardware object."""

View File

@ -56,7 +56,7 @@ class Discovery(CoreSysAttributes):
"""Send a discovery message to Home-Assistant.""" """Send a discovery message to Home-Assistant."""
message = Message(provider, component, platform, config) message = Message(provider, component, platform, config)
# Allready exists? # Already exists?
for exists_message in self.message_obj: for exists_message in self.message_obj:
if exists_message == message: if exists_message == message:
_LOGGER.warning("Found douplicate discovery message from %s", _LOGGER.warning("Found douplicate discovery message from %s",

View File

@ -92,9 +92,9 @@ class SnapshotManager(CoreSysAttributes):
if not await snapshot.load(): if not await snapshot.load():
return None return None
# Allready exists? # Already exists?
if snapshot.slug in self.snapshots_obj: if snapshot.slug in self.snapshots_obj:
_LOGGER.error("Snapshot %s allready exists!", snapshot.slug) _LOGGER.error("Snapshot %s already exists!", snapshot.slug)
return None return None
# Move snapshot to backup # Move snapshot to backup

View File

@ -137,7 +137,7 @@ class Snapshot(CoreSysAttributes):
self._data[ATTR_CRYPTO] = CRYPTO_AES128 self._data[ATTR_CRYPTO] = CRYPTO_AES128
def set_password(self, password): def set_password(self, password):
"""Set the password for a exists snapshot.""" """Set the password for an existing snapshot."""
if not password: if not password:
return False return False
@ -210,7 +210,7 @@ class Snapshot(CoreSysAttributes):
if not self.tarfile.is_file(): if not self.tarfile.is_file():
return self return self
# extract a exists snapshot # extract an existing snapshot
def _extract_snapshot(): def _extract_snapshot():
"""Extract a snapshot.""" """Extract a snapshot."""
with tarfile.open(self.tarfile, "r:") as tar: with tarfile.open(self.tarfile, "r:") as tar:
@ -252,7 +252,7 @@ class Snapshot(CoreSysAttributes):
addon_list = addon_list or self.sys_addons.list_installed addon_list = addon_list or self.sys_addons.list_installed
async def _addon_save(addon): async def _addon_save(addon):
"""Task to store a add-on into snapshot.""" """Task to store an add-on into snapshot."""
addon_file = SecureTarFile( addon_file = SecureTarFile(
Path(self._tmp.name, f"{addon.slug}.tar.gz"), Path(self._tmp.name, f"{addon.slug}.tar.gz"),
'w', key=self._key) 'w', key=self._key)
@ -285,7 +285,7 @@ class Snapshot(CoreSysAttributes):
addon_list.append(addon) addon_list.append(addon)
async def _addon_restore(addon): async def _addon_restore(addon):
"""Task to restore a add-on into snapshot.""" """Task to restore an add-on into snapshot."""
addon_file = SecureTarFile( addon_file = SecureTarFile(
Path(self._tmp.name, f"{addon.slug}.tar.gz"), Path(self._tmp.name, f"{addon.slug}.tar.gz"),
'r', key=self._key) 'r', key=self._key)

View File

@ -25,7 +25,7 @@ def password_for_validating(password):
def key_to_iv(key): def key_to_iv(key):
"""Generate a iv from Key.""" """Generate an iv from Key."""
for _ in range(100): for _ in range(100):
key = hashlib.sha256(key).digest() key = hashlib.sha256(key).digest()
return key[:16] return key[:16]

View File

@ -15,7 +15,7 @@ ALL_FOLDERS = [FOLDER_HOMEASSISTANT, FOLDER_SHARE, FOLDER_ADDONS, FOLDER_SSL]
def unique_addons(addons_list): def unique_addons(addons_list):
"""Validate that a add-on is unique.""" """Validate that an add-on is unique."""
single = set([addon[ATTR_SLUG] for addon in addons_list]) single = set([addon[ATTR_SLUG] for addon in addons_list])
if len(single) != len(addons_list): if len(single) != len(addons_list):

View File

@ -23,7 +23,7 @@ class Supervisor(CoreSysAttributes):
@property @property
def need_update(self): def need_update(self):
"""Return True if a update is available.""" """Return True if an update is available."""
return self.version != self.last_version return self.version != self.last_version
@property @property

View File

@ -53,7 +53,7 @@ class Tasks(CoreSysAttributes):
_LOGGER.info("All core tasks are scheduled") _LOGGER.info("All core tasks are scheduled")
async def _update_addons(self): async def _update_addons(self):
"""Check if a update is available of a addon and update it.""" """Check if an update is available for an addon and update it."""
tasks = [] tasks = []
for addon in self.sys_addons.list_addons: for addon in self.sys_addons.list_addons:
if not addon.is_installed or not addon.auto_update: if not addon.is_installed or not addon.auto_update:
@ -77,7 +77,7 @@ class Tasks(CoreSysAttributes):
if not self.sys_supervisor.need_update: if not self.sys_supervisor.need_update:
return return
# don't perform a update on beta/dev channel # don't perform an update on beta/dev channel
if self.sys_dev: if self.sys_dev:
_LOGGER.warning("Ignore Hass.io update on dev channel!") _LOGGER.warning("Ignore Hass.io update on dev channel!")
return return

View File

@ -81,7 +81,7 @@ class SecureTarFile:
def _generate_iv(key, salt): def _generate_iv(key, salt):
"""Generate a iv from data.""" """Generate an iv from data."""
temp_iv = key + salt temp_iv = key + salt
for _ in range(100): for _ in range(100):
temp_iv = hashlib.sha256(temp_iv).digest() temp_iv = hashlib.sha256(temp_iv).digest()