Coder Social home page Coder Social logo

wranger_final's Introduction

Wrangler

Installation

Wrangler requires the PyYaml library.

pip install pyyaml

Usage

usage: wrangler [-h] [--output-path OUTPUT_PATH] [paths ...]

Parses and transcribes yaml files to lua scripts

positional arguments:
  paths

options:
  -h, --help            show this help message and exit
  --output-path OUTPUT_PATH

Example: wrangler --output-path ./temp file.yaml path

Wrangler requires an output path to be specified with the flag --output-path. This path can be relative or absolute and will be created if it does not already exist.

The positional argument are paths to .yaml files. These paths can be either to a file or a directory. In the case of a directory, wrangler will search recursively in the directory for all .yaml files.

Developer Notes

Translators

The class LuaTranslator is an abstraction that keeps the parsing of the yaml files and the conversion to Lua separate.

It is passed to Script on instantiation in order to provide translation from input (yaml) to output (lua). This abstraction provides a simple implementation to introduce other language outputs.

A Translator simply provides a mapping of key value pairs, with keys being command types and values being the methods to translate them. It implements the native Python __call__ method, so the Script instance does not need to know anything about the Translators internals, only that calling the instance with a key/value pair will result in the appropriate translation.

str and repr

For testing purposes, these methods were implemented to provide a more flexible way to test the parsing of yaml files without needing to worry about comparing files written to disk or strings.

__str__ will return the contents that would be written to disk.

__repr__ returns a JSON output of the output data.

wranger_final's People

Contributors

ryanlong1004 avatar

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.