Skip to content

Commit

Permalink
Move constants to setup.py (home-assistant#10312)
Browse files Browse the repository at this point in the history
* Remove unused import

* Move setup relevant consts to 'setup.py'

* remove blank line

* Set source
  • Loading branch information
fabaff authored and balloob committed Nov 3, 2017
1 parent a43f99a commit 8132480
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 57 deletions.
16 changes: 6 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
#
import sys
import os
from os.path import relpath
import inspect
from homeassistant.const import (__version__, __short_version__, PROJECT_NAME,
PROJECT_LONG_DESCRIPTION,
PROJECT_COPYRIGHT, PROJECT_AUTHOR,
PROJECT_GITHUB_USERNAME,
PROJECT_GITHUB_REPOSITORY,
GITHUB_PATH, GITHUB_URL)

from homeassistant.const import __version__, __short_version__
from setup import (
PROJECT_NAME, PROJECT_LONG_DESCRIPTION, PROJECT_COPYRIGHT, PROJECT_AUTHOR,
PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY, GITHUB_PATH,
GITHUB_URL)

sys.path.insert(0, os.path.abspath('_ext'))
sys.path.insert(0, os.path.abspath('../homeassistant'))
Expand Down Expand Up @@ -87,9 +85,7 @@


def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
"""Determine the URL corresponding to Python object."""
if domain != 'py':
return None
modname = info['module']
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/dialogflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import voluptuous as vol

from homeassistant.const import PROJECT_NAME, HTTP_BAD_REQUEST
from homeassistant.const import HTTP_BAD_REQUEST
from homeassistant.helpers import intent, template
from homeassistant.components.http import HomeAssistantView

Expand All @@ -26,6 +26,8 @@

INTENTS_API_ENDPOINT = '/api/dialogflow'

SOURCE = "Home Assistant Dialogflow"

CONFIG_SCHEMA = vol.Schema({
DOMAIN: {}
}, extra=vol.ALLOW_EXTRA)
Expand Down Expand Up @@ -128,5 +130,5 @@ def as_dict(self):
return {
'speech': self.speech,
'displayText': self.speech,
'source': PROJECT_NAME,
'source': SOURCE,
}
7 changes: 5 additions & 2 deletions homeassistant/components/no_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (
CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME, HTTP_HEADER_AUTH,
HTTP_HEADER_USER_AGENT, PROJECT_EMAIL)
HTTP_HEADER_USER_AGENT)
from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE

_LOGGER = logging.getLogger(__name__)

DOMAIN = 'no_ip'

# We should set a dedicated address for the user agent.
EMAIL = '[email protected]'

INTERVAL = timedelta(minutes=5)

DEFAULT_TIMEOUT = 10
Expand All @@ -38,7 +41,7 @@
}

UPDATE_URL = 'https://dynupdate.noip.com/nic/update'
USER_AGENT = "{} {}".format(SERVER_SOFTWARE, PROJECT_EMAIL)
USER_AGENT = "{} {}".format(SERVER_SOFTWARE, EMAIL)

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
Expand Down
37 changes: 4 additions & 33 deletions homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,7 @@
REQUIRED_PYTHON_VER_WIN = (3, 5, 2)
CONSTRAINT_FILE = 'package_constraints.txt'

PROJECT_NAME = 'Home Assistant'
PROJECT_PACKAGE_NAME = 'homeassistant'
PROJECT_LICENSE = 'Apache License 2.0'
PROJECT_AUTHOR = 'The Home Assistant Authors'
PROJECT_COPYRIGHT = ' 2013, {}'.format(PROJECT_AUTHOR)
PROJECT_URL = 'https://home-assistant.io/'
PROJECT_EMAIL = '[email protected]'
PROJECT_DESCRIPTION = ('Open-source home automation platform '
'running on Python 3.')
PROJECT_LONG_DESCRIPTION = ('Home Assistant is an open-source '
'home automation platform running on Python 3. '
'Track and control all devices at home and '
'automate control. '
'Installation in less than a minute.')
PROJECT_CLASSIFIERS = [
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.4',
'Topic :: Home Automation'
]

PROJECT_GITHUB_USERNAME = 'home-assistant'
PROJECT_GITHUB_REPOSITORY = 'home-assistant'

PYPI_URL = 'https://pypi.python.org/pypi/{}'.format(PROJECT_PACKAGE_NAME)
GITHUB_PATH = '{}/{}'.format(PROJECT_GITHUB_USERNAME,
PROJECT_GITHUB_REPOSITORY)
GITHUB_URL = 'https://github.com/{}'.format(GITHUB_PATH)

# Format for platforms
PLATFORM_FORMAT = '{}.{}'

# Can be used to specify a catch all when registering state or event listeners.
Expand All @@ -48,8 +18,7 @@
# If no name is specified
DEVICE_DEFAULT_NAME = 'Unnamed Device'

WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']

# Sun events
SUN_EVENT_SUNSET = 'sunset'
SUN_EVENT_SUNRISE = 'sunrise'

Expand Down Expand Up @@ -463,3 +432,5 @@
TEMPERATURE = 'temperature' # type: str
SPEED_MS = 'speed_ms' # type: str
ILLUMINANCE = 'illuminance' # type: str

WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
5 changes: 2 additions & 3 deletions homeassistant/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""All methods needed to bootstrap a Home Assistant instance."""
import asyncio
import logging
import logging.handlers
import os
from timeit import default_timer as timer
Expand All @@ -9,13 +8,13 @@
from typing import Optional, Dict

import homeassistant.config as conf_util
from homeassistant.config import async_notify_setup_error
import homeassistant.core as core
import homeassistant.loader as loader
import homeassistant.util.package as pkg_util
from homeassistant.util.async import run_coroutine_threadsafe
from homeassistant.config import async_notify_setup_error
from homeassistant.const import (
EVENT_COMPONENT_LOADED, PLATFORM_FORMAT, CONSTRAINT_FILE)
from homeassistant.util.async import run_coroutine_threadsafe

_LOGGER = logging.getLogger(__name__)

Expand Down
45 changes: 38 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,46 @@
"""Home Assistant setup script."""
import os
from setuptools import setup, find_packages
from homeassistant.const import (__version__, PROJECT_PACKAGE_NAME,
PROJECT_LICENSE, PROJECT_URL,
PROJECT_EMAIL, PROJECT_DESCRIPTION,
PROJECT_CLASSIFIERS, GITHUB_URL,
PROJECT_AUTHOR)

from homeassistant.const import __version__

PROJECT_NAME = 'Home Assistant'
PROJECT_PACKAGE_NAME = 'homeassistant'
PROJECT_LICENSE = 'Apache License 2.0'
PROJECT_AUTHOR = 'The Home Assistant Authors'
PROJECT_COPYRIGHT = ' 2013-2017, {}'.format(PROJECT_AUTHOR)
PROJECT_URL = 'https://home-assistant.io/'
PROJECT_EMAIL = '[email protected]'
PROJECT_DESCRIPTION = ('Open-source home automation platform '
'running on Python 3.')
PROJECT_LONG_DESCRIPTION = ('Home Assistant is an open-source '
'home automation platform running on Python 3. '
'Track and control all devices at home and '
'automate control. '
'Installation in less than a minute.')
PROJECT_CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Home Automation'
]

PROJECT_GITHUB_USERNAME = 'home-assistant'
PROJECT_GITHUB_REPOSITORY = 'home-assistant'

PYPI_URL = 'https://pypi.python.org/pypi/{}'.format(PROJECT_PACKAGE_NAME)
GITHUB_PATH = '{}/{}'.format(
PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY)
GITHUB_URL = 'https://github.com/{}'.format(GITHUB_PATH)


HERE = os.path.abspath(os.path.dirname(__file__))
DOWNLOAD_URL = ('{}/archive/'
'{}.zip'.format(GITHUB_URL, __version__))
DOWNLOAD_URL = '{}/archive/{}.zip'.format(GITHUB_URL, __version__)

PACKAGES = find_packages(exclude=['tests', 'tests.*'])

Expand Down

0 comments on commit 8132480

Please sign in to comment.