Giter VIP home page Giter VIP logo

py2bash's Introduction

Purpose of a project.

The project aims to create a simple and convenient tool for converting scripts written in Python, in a sequence of bash commands.

Features supported(for, sequence, if-else, etc).

The program correctly converts the following language constructs of Python:

  • for i in range() (or xrange()) with different number of parameters to be passed in a similar construction shell bash: for (i = BEGIN; i <= END; i ++) or for i in {BEGIN..END};
  • implementation using the print output is converted to a similar design echo;
  • also processed string literals and numeric values.

Current approach used(python ast and node visitor).

To analyze and convert Python script commands in the program used class NodeVisitor module ast (Abstract Syntax Trees). Module 'ast' helps Python applications to process trees of the Python abstract syntax grammar. This module helps to find out programmatically what the current grammar looks like. In Abstract Syntax Trees (AST) as internal vertices are the operators of the programming language, as well as the leaves - the operands they passed. Thus, in contrast to the parse tree in AST does not include items that do not affect the semantics of the program, such as braces, semicolons, and so on, because the information about the division of the organization itself carries nodes in the tree.

Usage:

python main.py [-h] [-o {mem,spd}] [-v] pyscript pyscript - mandatory command-line argument specifies the file name * .py Optional arguments: -h, --help - displays the help message and exit the program; -o [mem,spd], --optimized [mem,spd] - optimizing code for efficient use of memory, or the maximum speed; -v, --verbose - enable verbose output.

Requirements:

Python 2.7.9

Reference.

Python ast module usage examples

py2bash's People

Contributors

ekondrashev avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

artem-sub grisov

py2bash's Issues

test_print is corrupted

test_print test is corrupted, it shows two tests execution while there are 4.
Lets fix the test removing redundant import.

Lets add README.md

Lets add readme in markdown format describing

  • purpose of a project
  • features supported(for, sequence, if-else, etc)
  • current approach used(python ast and node visitor)
  • usage
  • requirements(python version - 2.7, bash version - 3.2 - check yours plz)

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.