mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Make compatible with python 3 (#281)
* Make compatible with python 3 * Update travis * Env * Fix typo * Fix install correct platformio * Lint * Fix build flags * Lint * Upgrade pylint * Lint
This commit is contained in:
		| @@ -11,6 +11,7 @@ from esphomeyaml.const import CONF_CRON, CONF_DAYS_OF_MONTH, CONF_DAYS_OF_WEEK, | ||||
| from esphomeyaml.core import CORE | ||||
| from esphomeyaml.cpp_generator import add, Pvariable, ArrayInitializer | ||||
| from esphomeyaml.cpp_types import esphomelib_ns, Component, NoArg, Trigger, App | ||||
| from esphomeyaml.py_compat import string_types | ||||
|  | ||||
| _LOGGER = logging.getLogger(__name__) | ||||
|  | ||||
| @@ -30,9 +31,9 @@ def _tz_timedelta(td): | ||||
|     offset_second = int(abs(td.total_seconds())) % 60 | ||||
|     if offset_hour == 0 and offset_minute == 0 and offset_second == 0: | ||||
|         return '0' | ||||
|     elif offset_minute == 0 and offset_second == 0: | ||||
|     if offset_minute == 0 and offset_second == 0: | ||||
|         return '{}'.format(offset_hour) | ||||
|     elif offset_second == 0: | ||||
|     if offset_second == 0: | ||||
|         return '{}:{}'.format(offset_hour, offset_minute) | ||||
|     return '{}:{}:{}'.format(offset_hour, offset_minute, offset_second) | ||||
|  | ||||
| @@ -119,7 +120,7 @@ def detect_tz(): | ||||
|         import pytz | ||||
|     except ImportError: | ||||
|         raise vol.Invalid("No timezone specified and 'tzlocal' not installed. To automatically " | ||||
|                           "detect the timezone please install tzlocal (pip2 install tzlocal)") | ||||
|                           "detect the timezone please install tzlocal (pip install tzlocal)") | ||||
|     try: | ||||
|         tz = tzlocal.get_localzone() | ||||
|     except pytz.exceptions.UnknownTimeZoneError: | ||||
| @@ -131,7 +132,7 @@ def detect_tz(): | ||||
|  | ||||
| def _parse_cron_int(value, special_mapping, message): | ||||
|     special_mapping = special_mapping or {} | ||||
|     if isinstance(value, (str, unicode)) and value in special_mapping: | ||||
|     if isinstance(value, string_types) and value in special_mapping: | ||||
|         return special_mapping[value] | ||||
|     try: | ||||
|         return int(value) | ||||
| @@ -140,7 +141,7 @@ def _parse_cron_int(value, special_mapping, message): | ||||
|  | ||||
|  | ||||
| def _parse_cron_part(part, min_value, max_value, special_mapping): | ||||
|     if part == '*' or part == '?': | ||||
|     if part in ('*', '?'): | ||||
|         return set(x for x in range(min_value, max_value + 1)) | ||||
|     if '/' in part: | ||||
|         data = part.split('/') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user