Git Product home page Git Product logo

pyfranca's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.