mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
formatting
This commit is contained in:
@@ -4,7 +4,8 @@ import subprocess
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
root_path = os.path.abspath(os.path.normpath(os.path.join(__file__, "..", "..")))
|
||||
root_path = os.path.abspath(os.path.normpath(
|
||||
os.path.join(__file__, "..", "..")))
|
||||
basepath = os.path.join(root_path, "src")
|
||||
temp_folder = os.path.join(root_path, ".temp")
|
||||
temp_header_file = os.path.join(temp_folder, "all-include.cpp")
|
||||
@@ -18,6 +19,7 @@ def shlex_quote(s):
|
||||
|
||||
return "'" + s.replace("'", "'\"'\"'") + "'"
|
||||
|
||||
|
||||
def build_all_include():
|
||||
# Build a cpp file that includes all header files in this repo.
|
||||
# Otherwise header-only integrations would not be tested by clang-tidy
|
||||
@@ -36,6 +38,7 @@ def build_all_include():
|
||||
p.parent.mkdir(exist_ok=True)
|
||||
p.write_text(content)
|
||||
|
||||
|
||||
def src_files(filetypes=None):
|
||||
file_list = []
|
||||
for path in walk_files(basepath):
|
||||
@@ -45,24 +48,31 @@ def src_files(filetypes=None):
|
||||
file_list.append(path)
|
||||
return file_list
|
||||
|
||||
|
||||
def walk_files(path):
|
||||
for root, _, files in os.walk(path):
|
||||
for name in files:
|
||||
yield os.path.join(root, name)
|
||||
|
||||
|
||||
def get_output(*args):
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, err = proc.communicate()
|
||||
return output.decode("utf-8")
|
||||
|
||||
|
||||
def get_err(*args):
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, err = proc.communicate()
|
||||
return err.decode("utf-8")
|
||||
|
||||
|
||||
def splitlines_no_ends(string):
|
||||
return [s.strip() for s in string.splitlines()]
|
||||
|
||||
|
||||
def changed_files():
|
||||
check_remotes = ["upstream", "origin"]
|
||||
check_remotes.extend(splitlines_no_ends(get_output("git", "remote")))
|
||||
@@ -81,6 +91,7 @@ def changed_files():
|
||||
changed.sort()
|
||||
return changed
|
||||
|
||||
|
||||
def filter_changed(files):
|
||||
changed = changed_files()
|
||||
files = [f for f in files if f in changed]
|
||||
@@ -91,6 +102,7 @@ def filter_changed(files):
|
||||
print(f" {c}")
|
||||
return files
|
||||
|
||||
|
||||
def git_ls_files(patterns=None):
|
||||
command = ["git", "ls-files", "-s"]
|
||||
if patterns is not None:
|
||||
@@ -100,6 +112,7 @@ def git_ls_files(patterns=None):
|
||||
lines = [x.split() for x in output.decode("utf-8").splitlines()]
|
||||
return {s[3].strip(): int(s[0]) for s in lines}
|
||||
|
||||
|
||||
def load_idedata(environment):
|
||||
platformio_ini = Path(root_path) / "platformio.ini"
|
||||
temp_idedata = Path(temp_folder) / f"idedata-{environment}.json"
|
||||
@@ -113,7 +126,8 @@ def load_idedata(environment):
|
||||
if not changed:
|
||||
return json.loads(temp_idedata.read_text())
|
||||
|
||||
stdout = subprocess.check_output(["pio", "run", "-t", "idedata", "-e", environment])
|
||||
stdout = subprocess.check_output(
|
||||
["pio", "run", "-t", "idedata", "-e", environment])
|
||||
match = re.search(r'{\s*".*}', stdout.decode("utf-8"))
|
||||
data = json.loads(match.group())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user