mirror of
https://github.com/alexhopeoconnor/default.git
synced 2026-10-17 16:41:32 +10:00
Change action (#708)
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
from glob import glob
|
||||
|
||||
|
||||
def get_hacs_manifest():
|
||||
files = []
|
||||
for dir, _, _ in os.walk("/tmp/repositories/addition"):
|
||||
files.extend(glob(os.path.join(dir, "*hacs.json")))
|
||||
|
||||
if len(files) != 1:
|
||||
print("No HACS manifest")
|
||||
exit(1)
|
||||
|
||||
hacs_manifest = files.pop()
|
||||
print(
|
||||
f"Found HACS manifest at {hacs_manifest.replace('/tmp/repositories/addition','')}"
|
||||
)
|
||||
|
||||
with open(hacs_manifest, "r") as mf:
|
||||
hacs_manifest = json.loads(mf.read())
|
||||
|
||||
return hacs_manifest or {}
|
||||
@@ -1,21 +0,0 @@
|
||||
import os
|
||||
from scripts.helpers.hacs_manifest import get_hacs_manifest
|
||||
|
||||
ALTERNATIVES = {
|
||||
"info": ["info", "INFO", "info.md", "INFO.md", "info.MD", "INFO.MD"],
|
||||
"readme": ["readme", "README", "readme.md", "README.md", "readme.MD", "README.MD"],
|
||||
}
|
||||
|
||||
|
||||
def get_info():
|
||||
manifest = get_hacs_manifest()
|
||||
info = "readme" if manifest.get("render_readme", False) else "info"
|
||||
|
||||
content = ""
|
||||
|
||||
for alternative in ALTERNATIVES[info]:
|
||||
if os.path.exists(f"/tmp/repositories/addition/{alternative}"):
|
||||
print(f"Found info file at /{alternative}")
|
||||
with open(f"/tmp/repositories/addition/{alternative}", "r") as alt:
|
||||
content = alt.read()
|
||||
return content
|
||||
Reference in New Issue
Block a user