Implemented TactilityKernel and DevicetreeCompiler, updated licenses & copyrights (#452)
**New features** - Created a devicetree DTS and YAML parser in Python - Created new modules: - TactilityKernel (LGPL v3.0 license) - Platforms/PlatformEsp32 (LGPL v3.0 license) - Platforms/PlatformPosix (LGPL v3.0 license) - Tests/TactilityKernelTests Most boards have a placeholder DTS file, while T-Lora Pager has a few devices attached. **Licenses** Clarified licenses and copyrights better. - Add explanation about the intent behind them. - Added explanation about licenses for past and future subprojects - Added more details explanations with regards to the logo usage - Copied licenses to subprojects to make it more explicit
This commit is contained in:
committed by
GitHub
parent
0d16eb606f
commit
4b6ed871a9
@@ -0,0 +1,57 @@
|
||||
import yaml
|
||||
import os
|
||||
from .models import Binding, BindingProperty
|
||||
|
||||
def parse_binding(file_path: str, binding_dirs: list[str]) -> Binding:
|
||||
with open(file_path, 'r') as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
description = data.get('description', '')
|
||||
bus = data.get('bus', None)
|
||||
properties_dict = {}
|
||||
|
||||
# Handle inclusions
|
||||
includes = data.get('include', [])
|
||||
all_includes = list(includes) # Copy for iteration
|
||||
for include_file in includes:
|
||||
include_path = None
|
||||
for binding_dir in binding_dirs:
|
||||
potential_path = os.path.join(binding_dir, include_file)
|
||||
if os.path.exists(potential_path):
|
||||
include_path = potential_path
|
||||
break
|
||||
|
||||
if not include_path:
|
||||
print(f"Warning: Could not find include file {include_file}")
|
||||
continue
|
||||
|
||||
parent_binding = parse_binding(include_path, binding_dirs)
|
||||
if not description and parent_binding.description:
|
||||
description = parent_binding.description
|
||||
if not bus and parent_binding.bus:
|
||||
bus = parent_binding.bus
|
||||
for prop in parent_binding.properties:
|
||||
properties_dict[prop.name] = prop
|
||||
for include in parent_binding.includes:
|
||||
all_includes.append(include)
|
||||
|
||||
# Parse local properties
|
||||
compatible = data.get('compatible', None)
|
||||
properties_raw = data.get('properties', {})
|
||||
for name, details in properties_raw.items():
|
||||
prop = BindingProperty(
|
||||
name=name,
|
||||
type=details.get('type', 'unknown'),
|
||||
required=details.get('required', False),
|
||||
description=details.get('description', '').strip(),
|
||||
)
|
||||
properties_dict[name] = prop
|
||||
filename = os.path.basename(file_path)
|
||||
return Binding(
|
||||
filename=filename,
|
||||
compatible=compatible,
|
||||
description=description.strip(),
|
||||
properties=list(properties_dict.values()),
|
||||
includes=all_includes,
|
||||
bus=bus
|
||||
)
|
||||
Reference in New Issue
Block a user