Update docstrings (#8536)

This commit is contained in:
Fabian Affolter 2017-07-18 16:23:57 +02:00 committed by GitHub
parent 4ae11c009d
commit 879c816f5c
2 changed files with 46 additions and 46 deletions

View file

@ -40,7 +40,7 @@ def from_config_dict(config: Dict[str, Any],
skip_pip: bool=False,
log_rotate_days: Any=None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a config dict.
"""Try to configure Home Assistant from a configuration dictionary.
Dynamically loads required components and its dependencies.
"""
@ -71,7 +71,7 @@ def async_from_config_dict(config: Dict[str, Any],
skip_pip: bool=False,
log_rotate_days: Any=None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a config dict.
"""Try to configure Home Assistant from a configuration dictionary.
Dynamically loads required components and its dependencies.
This method is a coroutine.
@ -92,8 +92,8 @@ def async_from_config_dict(config: Dict[str, Any],
hass.config.skip_pip = skip_pip
if skip_pip:
_LOGGER.warning('Skipping pip installation of required modules. '
'This may cause issues.')
_LOGGER.warning("Skipping pip installation of required modules. "
"This may cause issues")
if not loader.PREPARED:
yield from hass.async_add_job(loader.prepare, hass)
@ -118,13 +118,13 @@ def async_from_config_dict(config: Dict[str, Any],
# pylint: disable=not-an-iterable
res = yield from core_components.async_setup(hass, config)
if not res:
_LOGGER.error('Home Assistant core failed to initialize. '
'Further initialization aborted.')
_LOGGER.error("Home Assistant core failed to initialize. "
"further initialization aborted")
return hass
yield from persistent_notification.async_setup(hass, config)
_LOGGER.info('Home Assistant core initialized')
_LOGGER.info("Home Assistant core initialized")
# stage 1
for component in components:
@ -143,7 +143,7 @@ def async_from_config_dict(config: Dict[str, Any],
yield from hass.async_block_till_done()
stop = time()
_LOGGER.info('Home Assistant initialized in %.2fs', stop-start)
_LOGGER.info("Home Assistant initialized in %.2fs", stop-start)
async_register_signal_handling(hass)
return hass
@ -193,7 +193,7 @@ def async_from_config_file(config_path: str,
config_dict = yield from hass.async_add_job(
conf_util.load_yaml_config_file, config_path)
except HomeAssistantError as err:
_LOGGER.error('Error loading %s: %s', config_path, err)
_LOGGER.error("Error loading %s: %s", config_path, err)
return None
finally:
clear_secret_cache()

View file

@ -40,7 +40,7 @@ CONFIG_DIR_NAME = '.homeassistant'
DATA_CUSTOMIZE = 'hass_customize'
FILE_MIGRATION = [
["ios.conf", ".ios.conf"],
['ios.conf', '.ios.conf'],
]
DEFAULT_CORE_CONFIG = (
@ -71,7 +71,7 @@ config:
http:
# Uncomment this to add a password (recommended!)
# api_password: PASSWORD
# Uncomment this if you are using SSL or running in Docker etc
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# base_url: example.duckdns.org:8123
# Checks for available updates
@ -89,7 +89,7 @@ discovery:
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Enables support for tracking state changes over time.
# Enables support for tracking state changes over time
history:
# View all events in a logbook
@ -98,13 +98,13 @@ logbook:
# Track the sun
sun:
# Weather Prediction
# Weather prediction
sensor:
platform: yr
- platform: yr
# Text to speech
tts:
platform: google
- platform: google
group: !include groups.yaml
automation: !include automations.yaml
@ -141,17 +141,17 @@ CORE_CONFIG_SCHEMA = CUSTOMIZE_CONFIG_SCHEMA.extend({
def get_default_config_dir() -> str:
"""Put together the default configuration directory based on OS."""
"""Put together the default configuration directory based on the OS."""
data_dir = os.getenv('APPDATA') if os.name == "nt" \
else os.path.expanduser('~')
return os.path.join(data_dir, CONFIG_DIR_NAME)
def ensure_config_exists(config_dir: str, detect_location: bool=True) -> str:
"""Ensure a config file exists in given configuration directory.
"""Ensure a configuration file exists in given configuration directory.
Creating a default one if needed.
Return path to the config file.
Return path to the configuration file.
"""
config_path = find_config_file(config_dir)
@ -195,8 +195,8 @@ def create_default_config(config_dir, detect_location=True):
info[attr] = getattr(location_info, prop) or default
if location_info.latitude and location_info.longitude:
info[CONF_ELEVATION] = loc_util.elevation(location_info.latitude,
location_info.longitude)
info[CONF_ELEVATION] = loc_util.elevation(
location_info.latitude, location_info.longitude)
# Writing files with YAML does not create the most human readable results
# So we're hard coding a YAML template.
@ -225,16 +225,16 @@ def create_default_config(config_dir, detect_location=True):
return config_path
except IOError:
print('Unable to create default configuration file', config_path)
print("Unable to create default configuration file", config_path)
return None
@asyncio.coroutine
def async_hass_config_yaml(hass):
"""Load YAML from hass config File.
"""Load YAML from a Home Assistant configuration file.
This function allow component inside asyncio loop to reload his config by
self.
This function allow a component inside the asyncio loop to reload its
configuration by itself.
This method is a coroutine.
"""
@ -269,7 +269,7 @@ def load_yaml_config_file(config_path):
getattr(err, 'filename', err)))
if not isinstance(conf_dict, dict):
msg = 'The configuration file {} does not contain a dictionary'.format(
msg = "The configuration file {} does not contain a dictionary".format(
os.path.basename(config_path))
_LOGGER.error(msg)
raise HomeAssistantError(msg)
@ -278,7 +278,7 @@ def load_yaml_config_file(config_path):
def process_ha_config_upgrade(hass):
"""Upgrade config if necessary.
"""Upgrade configuration if necessary.
This method needs to run in an executor.
"""
@ -294,8 +294,8 @@ def process_ha_config_upgrade(hass):
if conf_version == __version__:
return
_LOGGER.info('Upgrading config directory from %s to %s', conf_version,
__version__)
_LOGGER.info("Upgrading configuration directory from %s to %s",
conf_version, __version__)
if LooseVersion(conf_version) < LooseVersion('0.49'):
# 0.49 introduced persistent deps dir.
@ -306,20 +306,20 @@ def process_ha_config_upgrade(hass):
with open(version_path, 'wt') as outp:
outp.write(__version__)
_LOGGER.info('Migrating old system config files to new locations')
_LOGGER.info("Migrating old system configuration files to new locations")
for oldf, newf in FILE_MIGRATION:
if os.path.isfile(hass.config.path(oldf)):
_LOGGER.info('Migrating %s to %s', oldf, newf)
_LOGGER.info("Migrating %s to %s", oldf, newf)
os.rename(hass.config.path(oldf), hass.config.path(newf))
@callback
def async_log_exception(ex, domain, config, hass):
"""Generate log exception for config validation.
"""Generate log exception for configuration validation.
This method must be run in the event loop.
"""
message = 'Invalid config for [{}]: '.format(domain)
message = "Invalid config for [{}]: ".format(domain)
if hass is not None:
async_notify_setup_error(hass, domain, True)
@ -344,7 +344,7 @@ def async_log_exception(ex, domain, config, hass):
@asyncio.coroutine
def async_process_ha_core_config(hass, config):
"""Process the [homeassistant] section from the config.
"""Process the [homeassistant] section from the configuration.
This method is a coroutine.
"""
@ -362,7 +362,7 @@ def async_process_ha_core_config(hass, config):
hac.time_zone = time_zone
date_util.set_default_time_zone(time_zone)
else:
_LOGGER.error('Received invalid time zone %s', time_zone_str)
_LOGGER.error("Received invalid time zone %s", time_zone_str)
for key, attr in ((CONF_LATITUDE, 'latitude'),
(CONF_LONGITUDE, 'longitude'),
@ -374,7 +374,7 @@ def async_process_ha_core_config(hass, config):
if CONF_TIME_ZONE in config:
set_time_zone(config.get(CONF_TIME_ZONE))
# init whitelist external dir
# Init whitelist external dir
hac.whitelist_external_dirs = set((hass.config.path('www'),))
if CONF_WHITELIST_EXTERNAL_DIRS in config:
hac.whitelist_external_dirs.update(
@ -394,7 +394,7 @@ def async_process_ha_core_config(hass, config):
try:
pkg_cust = CUSTOMIZE_CONFIG_SCHEMA(pkg_cust)
except vol.Invalid:
_LOGGER.warning('Package %s contains invalid customize', name)
_LOGGER.warning("Package %s contains invalid customize", name)
continue
cust_exact.update(pkg_cust[CONF_CUSTOMIZE])
@ -415,9 +415,9 @@ def async_process_ha_core_config(hass, config):
hac.units = METRIC_SYSTEM
else:
hac.units = IMPERIAL_SYSTEM
_LOGGER.warning("Found deprecated temperature unit in core config, "
"expected unit system. Replace '%s: %s' with "
"'%s: %s'", CONF_TEMPERATURE_UNIT, unit,
_LOGGER.warning("Found deprecated temperature unit in core "
"configuration expected unit system. Replace '%s: %s' "
"with '%s: %s'", CONF_TEMPERATURE_UNIT, unit,
CONF_UNIT_SYSTEM, hac.units.name)
# Shortcut if no auto-detection necessary
@ -434,7 +434,7 @@ def async_process_ha_core_config(hass, config):
loc_util.detect_location_info)
if info is None:
_LOGGER.error('Could not detect location information')
_LOGGER.error("Could not detect location information")
return
if hac.latitude is None and hac.longitude is None:
@ -463,8 +463,8 @@ def async_process_ha_core_config(hass, config):
if discovered:
_LOGGER.warning(
'Incomplete core config. Auto detected %s',
', '.join('{}: {}'.format(key, val) for key, val in discovered))
"Incomplete core configuration. Auto detected %s",
", ".join('{}: {}'.format(key, val) for key, val in discovered))
def _log_pkg_error(package, component, config, message):
@ -495,7 +495,7 @@ def _identify_config_schema(module):
def merge_packages_config(config, packages):
"""Merge packages into the top-level config. Mutate config."""
"""Merge packages into the top-level configuration. Mutate config."""
# pylint: disable=too-many-nested-blocks
PACKAGES_CONFIG_SCHEMA(packages)
for pack_name, pack_conf in packages.items():
@ -549,7 +549,7 @@ def merge_packages_config(config, packages):
if comp_name in config:
_log_pkg_error(
pack_name, comp_name, config, "may occur only once"
" and it already exist in your main config")
" and it already exist in your main configuration")
continue
config[comp_name] = comp_conf
@ -558,7 +558,7 @@ def merge_packages_config(config, packages):
@callback
def async_process_component_config(hass, config, domain):
"""Check component config and return processed config.
"""Check component configuration and return processed configuration.
Raise a vol.Invalid exception on error.
@ -619,7 +619,7 @@ def async_process_component_config(hass, config, domain):
@asyncio.coroutine
def async_check_ha_config_file(hass):
"""Check if HA config file valid.
"""Check if Home Assistant configuration file is valid.
This method is a coroutine.
"""