$ show cogu/autosar
This repository provides a Python library for creating, reading, and writing AUTOSAR XML (ARXML) files, targeting Classic AUTOSAR platforms from R19-11 to R22-11. It covers a broad range of AUTOSAR elementsβsoftware components, port interfaces, data types, constants, compu methods, service needs, and moreβthrough an object-oriented model with full XML serialization. The library is not an end-user application but a tool for automotive engineers and tool integrators to programmatically generate ARXML artifacts for import into commercial AUTOSAR toolchains. It also includes an early-stage code generator that produces C type definitions (Rte_Type.h) from the XML model. The architecture follows a layered design: an XML model layer (autosar.xml) with element classes, enums, and references; a workspace abstraction that manages packages, documents, and template application; and a generator layer that transforms the XML model into an intermediate representation for code generation. A notable design pattern is the template system (ElementTemplate/GenericTemplate) that decouples high-level element recipes from their serialization, enabling config-driven generation of entire projects from TOML configuration files. The library is supported by a comprehensive test suite that exercises round-trip XML serialization for hundreds of element types. The codebase shows good craftsmanshipβclean separation of concerns, consistent use of base classes (Identifiable, Describable), version-aware enum handling, and typed reference system. However, it is still in development (v0.5.7) with many planned releases and a roadmap that implies future breaking changes. Several AUTOSAR elements remain unimplemented, and the test suite relies on exact XML string comparisons, making it brittle. The project is maintained by a single contributor with no PyPI release, posing adoption and continuity risks. Overall, it is a solid, functional library for its domain but not yet production-ready for all use cases.
The LLM identified 3 files worth highlighting for reuse:
Defines a comprehensive bidirectional mapping between AUTOSAR XML string values and Python enumerations. The VersionedEnumValue and VersionedTextValue classes handle enum values that are valid only for specific schema versions, ensuring safe evolution across AUTOSAR releases. This pattern is self-contained and reusable for any XML schema with versioned enumerations, offering a clean separation between string representation and version constraints.
Provides abstract ElementTemplate and GenericTemplate classes that decouple high-level element recipes from their final ARXML serialization. Templates declare dependencies (via depends_on) and are applied through Workspace.apply(), which automatically creates packages, resolves references, and generates documents. This pattern is reusable for any domain where XML documents are generated from composable, dataless template objects, enabling config-driven generation.
Implements a system of typed reference classes (BaseRef subclasses) for AUTOSAR cross-references, with accepted_sub_types() enforcing type safety. Each reference carries a dest attribute and supports string-to-reference coercion (e.g., passing '/pkg/Element' generates the correct typed Ref). This pattern is reusable for any XML model that requires type-safe cross-document references, reducing runtime errors.