Giter Site home page Giter Site logo

Comments (2)

MGlauer avatar MGlauer commented on July 30, 2024

This looks like the wrong function call. Everything in the cli.py is intended to be called via the command line interface (hence the name). They look like callable python functions, but the @-wrappers actually change how the function call works. What you want is what is inside the function, i.e.:

from omi.dialects import get_dialect

file_path = "in.json"
o = "out.json" # or None for printing
f = "oep-v1.4"
t = "oep-v1.4"

with open(file_path, "r") as infile:
        from_dialect = get_dialect(f)()
        obj = from_dialect.parse(infile.read())
        to_dialect = get_dialect(t)()
        s = to_dialect.compile_and_render(obj)
        if o:
            with open(o, "w") as outfile:
                outfile.write(s)
        else:
            print(s)

Instead of loading the dialects dynamically (get_dialect(f)(), etc.), you can also use the respective dialect directly:
from_dialect = to_dialect = OEP_V_1_4_Dialect

from omi.

nesnoj avatar nesnoj commented on July 30, 2024

Thanks @MGlauer, works like a charm 👍

from omi.

Related Issues (20)

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.