Giter Site home page Giter Site logo

async2rewrite's Introduction

https://github.com/TheTrain2000/async2rewrite/blob/master/logo.png?raw=true

Automatically convert discord.py async branch code to rewrite branch code.

async2rewrite does not complete 100% of the necessary conversions. It is a tool designed to minimize the amount of tedious work required. async2rewrite will warn upon changes that it cannot make itself. Make sure to read the migration documentation for rewrite when using this tool.

Migration Documentation

Installation

python -m pip install -U async2rewrite

Usage

Command Line

When converting files via the command line, async2rewrite will create a new Python file with the specified suffix. If no suffix is specified, the default suffix is used.

For file paths, a path to a directory may also be passed. The library will locate all Python files recursively inside of the passed directory.

Single File

python -m async2rewrite file/path

Multiple Files

async2rewrite can automatically convert multiple files at once.

python -m async2rewrite file/path1 file/path2 ...

Specifying a Suffix

Use the --suffix flag to denote a custom suffix to add the the new file. The default suffix is .a2r.py.

Example:

python -m async2rewrite file/path --suffix .my_suffix.py

Printing the Output

If you would like to print the output instead of writing to a new file, the --print flag can be used.

Example:

python -m async2rewrite file/path --print

Running Interactive Mode

async2rewrite provides an option to convert using an interactive mode. The interactive mode will prompt your before every change that it makes.

Example:

python -m async2rewrite file/path --interactive

Module

Converting a File

import async2rewrite

file_result = async2rewrite.from_file('file/path')
print(file_result) # file_result contains the converted code.

Multiple files can be converted by passing an unpacked list into from_file().

Example:

async2rewrite.from_file('file/path', 'file/path2', 'file/path3', ...)

Converting from Text

import async2rewrite

text_result = async2rewrite.from_text('async def on_command_error(ctx, error): pass')
print(text_result) # text_result contains the converted code.

Getting Statistics

import async2rewrite

stats = async2rewrite.from_file('file/path', stats=True)
print(stats) # stats=True makes from_x return a collections Counter.

Thanks

  • Pantsu for forking and editing astunparse to not insert unnecessary parentheses.
  • Reina for the logo idea

async2rewrite's People

Contributors

tylergibbs2 avatar simmsb avatar gorialis avatar henry232323 avatar

Watchers

 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.