Skip to content

A Python module and tools for working with Franca interface definition language (IDL) models.

License

Notifications You must be signed in to change notification settings

zayfod/pyfranca

Repository files navigation

PyFranca

Documentation Status Build Status Coverage Status Scrutinizer Code Quality PyPI Version

Introduction

PyFranca is a Python module and tools for working with Franca interface definition language (IDL) files (.fidl). It is entirely written in Python and intended to be used as a base for developing code generation and processing tools.

PyFranca provides:

  • abstract syntax tree (AST) representation for a subset of the Franca IDL v0.9.2 .
  • a lexer and parser for the Franca IDL, based on Python Lex-Yacc (PLY).
  • a processor for Franca IDL files that handles model imports and type references.
  • a .fidl file command-line validator

The following extensions are envisioned:

  • AST serializer
  • diff tool for .fidl files for detecting interface changes

This project is a tool for exploring the capabilities (and ambiguities) of Franca. It is unstable and heavily under development.

Library Usage

Processing Franca IDL:

from pyfranca import Processor

processor = Processor()
processor.import_string("hello.fidl", """
    package Example
    interface Interface {
        method Hello {}
    }
""")
        
assert processor.packages["Example"].interfaces["Interface"].methods["Hello"].name == "Hello"

Listing the packages and interfaces, defined in a .fidl file:

from pyfranca import Processor, LexerException, ParserException, ProcessorException

processor = Processor()
try:
    processor.import_file("hello.fidl")        
except (LexerException, ParserException, ProcessorException) as e:
    print("ERROR: {}".format(e))

for package in processor.packages.values():
    print(package.name)
    for interface in package.interfaces.values():
        print("\t", interface.name)

Tool Usage

Visualizing Franca models:

fidl_dump.py model.fidl

Validating Franca models:

fidl_validator.py -I packages model.fidl

Limitations

The following Franca features are not supported:

  • dots in type collection and interface names
  • complex constants
  • expressions
  • unions
  • method overloading
  • method error extending
  • contracts

Requirements

  • Python 2.7 or 3.4
  • PLY

Installation

Using pip:

pip install pyfranca

From source:

git clone http://github.com/zayfod/pyfranca.git
cd pyfranca
python setup.py install

Documentation

API documentation is available here:

http://pyfranca.readthedocs.io/

Bugs

Bug reports and patches should be sent via GitHub:

http://github.com/zayfod/pyfranca

About

A Python module and tools for working with Franca interface definition language (IDL) models.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages