mirror of
https://github.com/esphome/esphome.git
synced 2025-06-18 14:25:48 +01:00
🏗 Merge C++ into python codebase (#504)
## Description: Move esphome-core codebase into esphome (and a bunch of other refactors). See https://github.com/esphome/feature-requests/issues/97 Yes this is a shit ton of work and no there's no way to automate it :( But it will be worth it 👍 Progress: - Core support (file copy etc): 80% - Base Abstractions (light, switch): ~50% - Integrations: ~10% - Working? Yes, (but only with ported components). Other refactors: - Moves all codegen related stuff into a single class: `esphome.codegen` (imported as `cg`) - Rework coroutine syntax - Move from `component/platform.py` to `domain/component.py` structure as with HA - Move all defaults out of C++ and into config validation. - Remove `make_...` helpers from Application class. Reason: Merge conflicts with every single new integration. - Pointer Variables are stored globally instead of locally in setup(). Reason: stack size limit. Future work: - Rework const.py - Move all `CONF_...` into a conf class (usage `conf.UPDATE_INTERVAL` vs `CONF_UPDATE_INTERVAL`). Reason: Less convoluted import block - Enable loading from `custom_components` folder. **Related issue (if applicable):** https://github.com/esphome/feature-requests/issues/97 **Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here> ## Checklist: - [ ] The code change is tested and works locally. - [ ] Tests have been added to verify that the new code works (under `tests/` folder). If user exposed functionality or configuration variables are added/changed: - [ ] Documentation added/updated in [esphomedocs](https://github.com/OttoWinter/esphomedocs).
This commit is contained in:
.clang-format.clang-tidy.gitignore.travis.ymlLICENSEMANIFEST.in
esphome
__main__.pyautomation.pycodegen.pyconfig.pyconfig_validation.pyconst.pycore.py
platformio.inirequirements.txtrequirements_test.txtcomponents
a4988
adc
ads1115.pyads1115
apds9960.pyapds9960
api
__init__.pyapi.protoapi_message.cppapi_message.hapi_server.cppapi_server.hbasic_messages.cppbasic_messages.hcommand_messages.cppcommand_messages.hlist_entities.cpplist_entities.hservice_call_message.cppservice_call_message.hsubscribe_logs.cppsubscribe_logs.hsubscribe_state.cppsubscribe_state.huser_services.cppuser_services.hutil.cpputil.h
bang_bang
bh1750
binary
binary_sensor
__init__.pyapds9960.pyautomation.cppautomation.hbinary_sensor.cppbinary_sensor.hcustom.pyesp32_ble_tracker.pyesp32_touch.pyfilter.cppfilter.hgpio.pyhomeassistant.pympr121.pynextion.pypn532.pyrdm6300.pyremote_receiver.pystatus.pytemplate.pyttp229_lsf.py
ble_presence
ble_rssi
bme280
bme680
bmp085
bmp280
climate
__init__.pyautomation.hbang_bang.pyclimate.cppclimate.hclimate_mode.cppclimate_mode.hclimate_traits.cppclimate_traits.h
cover
cse7766
custom
custom_component.pycustom_component
cwww
dallas.pydallas
debug.pydebug
deep_sleep.pydeep_sleep
dht
dht12
display
__init__.pydisplay_buffer.cppdisplay_buffer.hlcd_gpio.pylcd_pcf8574.pymax7219.pynextion.pyssd1306_i2c.pyssd1306_spi.pywaveshare_epaper.py
duty_cycle
endstop
esp32_ble_beacon.pyesp32_ble_beacon
esp32_ble_tracker.pyesp32_ble_tracker
esp32_camera
esp32_hall
esp32_touch.pyesp32_touch
esp8266_pwm
ethernet.pyethernet
fan
fastled_base
fastled_clockless
fastled_spi
font
globals.pyglobals
gpio
hdc1080
hlw8012
hmc5883l
homeassistant
htu21d
hx711
i2c.pyi2c
image
ina219
ina3221
interval.pyinterval
json
lcd_base
lcd_gpio
lcd_pcf8574
ledc
light
__init__.pyaddressable_light.haddressable_light_effect.hautomation.hbase_light_effects.hbinary.pycwww.pyfastled_clockless.pyfastled_spi.pylight_color_values.hlight_effect.hlight_output.hlight_state.cpplight_state.hlight_traits.hlight_transformer.hmonochromatic.pyneopixelbus.pypartition.pyrgb.pyrgbw.pyrgbww.py
logger.pylogger
max31855
max6675
max7219
mcp23017.pymcp23017
mhz19
monochromatic
mpr121.pympr121
mpu6050
mqtt.pymqtt
__init__.pymqtt_binary_sensor.cppmqtt_binary_sensor.hmqtt_client.cppmqtt_client.hmqtt_climate.cppmqtt_climate.hmqtt_component.cppmqtt_component.hmqtt_cover.cppmqtt_cover.hmqtt_fan.cppmqtt_fan.hmqtt_light.cppmqtt_light.hmqtt_sensor.cppmqtt_sensor.hmqtt_switch.cppmqtt_switch.hmqtt_text_sensor.cppmqtt_text_sensor.h
mqtt_subscribe
ms5611
my9231.pymy9231
neopixelbus
nextion
ota.pyota
output
__init__.pyautomation.cppautomation.hbinary_output.hcopy.pyesp8266_pwm.pyfloat_output.cppfloat_output.hgpio.pyledc.pymy9231.pypca9685.py
switch
partition
pca9685.pypca9685
pcf8574.pypcf8574
pmsx003
pn532.pypn532
power_supply.pypower_supply
pulse_counter
pulse_width
rdm6300.pyrdm6300
remote_base
__init__.pyjvc_protocol.cppjvc_protocol.hlg_protocol.cpplg_protocol.hnec_protocol.cppnec_protocol.hpanasonic_protocol.cpppanasonic_protocol.hraw_protocol.cppraw_protocol.hrc5_protocol.cpprc5_protocol.hrc_switch_protocol.cpprc_switch_protocol.hremote_base.cppremote_base.hsamsung_protocol.cppsamsung_protocol.hsony_protocol.cppsony_protocol.h
remote_receiver.pyremote_receiver
remote_transmitter.pyremote_transmitter
__init__.pyremote_transmitter.cppremote_transmitter.hremote_transmitter_esp32.cppremote_transmitter_esp8266.cppswitch.py
restart
rgb
rgbw
rgbww
rotary_encoder
script.pyscript
sds011
sensor
__init__.pyadc.pyapds9960.pyautomation.cppautomation.hbh1750.pyble_rssi.pybme280.pybme680.pybmp085.pybmp280.pycse7766.pycustom.pydallas.pydht.pydht12.pyduty_cycle.pyesp32_hall.pyfilter.cppfilter.hhdc1080.pyhlw8012.pyhmc5883l.pyhomeassistant.pyhtu21d.pyhx711.pyina219.pyina3221.pymax31855.pymax6675.pymhz19.pympu6050.pymqtt_subscribe.pyms5611.pypmsx003.pypulse_counter.pyrotary_encoder.pysds011.pysensor.cppsensor.hsht3xd.pytcs34725.pytemplate.pytotal_daily_energy.pytsl2561.pyultrasonic.pyuptime.pywifi_signal.pyxiaomi_miflora.pyxiaomi_mijia.py
servo.pyservo
sht3xd
shutdown
sntp
speed
spi.pyspi
ssd1306_base
ssd1306_i2c
ssd1306_spi
status
status_led.pystatus_led
stepper
substitutions
switch
__init__.pyautomation.cppautomation.hcustom.pygpio.pyoutput.pyremote_transmitter.pyrestart.pyshutdown.pyswitch.cppswitch.htemplate.pyuart.py
tcs34725
template
text_sensor
__init__.pyautomation.cppautomation.hcustom.pyhomeassistant.pymqtt_subscribe.pytemplate.pytext_sensor.cpptext_sensor.hversion.pywifi_info.py
time
time_based
total_daily_energy
tsl2561
ttp229_lsf.pyttp229_lsf
uart.pyuart
uln2003
ultrasonic
uptime
version
waveshare_epaper
web_server.pyweb_server
wifi.pywifi
wifi_info
wifi_signal
xiaomi_ble
xiaomi_miflora
xiaomi_mijia
core
application.cppapplication.hautomation.cppautomation.hautomation.tcccomponent.cppcomponent.hcontroller.cppcontroller.hdefines.hesphal.cppesphal.hhelpers.cpphelpers.hlog.cpplog.hoptional.hpreferences.cpppreferences.hutil.cpputil.h
core_config.pycpp_generator.pycpp_helpers.pycpp_types.pyespota.pyespota2.pyhelpers.pypins.pyplatformio_api.pypy_compat.pystorage_json.pyutil.pyvoluptuous_schema.pywizard.pywriter.pyyaml_util.pyscript
.neopixelbus.patchci-custom.pyci-suggest-changesclang-format.pyclang-tidy.pylint-cpplint-pythonsetuptest
tests
53
script/ci-custom.py
Executable file
53
script/ci-custom.py
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
import collections
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
|
||||
def find_all(a_str, sub):
|
||||
for i, line in enumerate(a_str.splitlines()):
|
||||
column = 0
|
||||
while True:
|
||||
column = line.find(sub, column)
|
||||
if column == -1:
|
||||
break
|
||||
yield i, column
|
||||
column += len(sub)
|
||||
|
||||
|
||||
files = []
|
||||
for root, _, fs in os.walk('esphome'):
|
||||
for f in fs:
|
||||
_, ext = os.path.splitext(f)
|
||||
if ext in ('.h', '.c', '.cpp', '.tcc', '.py'):
|
||||
files.append(os.path.join(root, f))
|
||||
files.sort()
|
||||
|
||||
errors = collections.defaultdict(list)
|
||||
for f in files:
|
||||
try:
|
||||
with codecs.open(f, 'r', encoding='utf-8') as f_handle:
|
||||
content = f_handle.read()
|
||||
except UnicodeDecodeError:
|
||||
errors[f].append("File is not readable as UTF-8. Please set your editor to UTF-8 mode.")
|
||||
continue
|
||||
for line, col in find_all(content, '\t'):
|
||||
errors[f].append("File contains tab character on line {}:{}. "
|
||||
"Please convert tabs to spaces.".format(line, col))
|
||||
for line, col in find_all(content, '\r'):
|
||||
errors[f].append("File contains windows newline on line {}:{}. "
|
||||
"Please set your editor to unix newline mode.".format(line, col))
|
||||
if content and not content.endswith('\n'):
|
||||
errors[f].append("File does not end with a newline, please add an empty line at the end of "
|
||||
"the file.")
|
||||
|
||||
for f, errs in errors.items():
|
||||
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(f))
|
||||
for err in errs:
|
||||
print(err)
|
||||
print()
|
||||
|
||||
sys.exit(len(errors))
|
Reference in New Issue
Block a user