Skip to main content

code refactorings with Python idioms

Project description

Refactoring non-idiomatic Python code with Python idioms

Install:

For command line use, the package is installed with

python3 -m pip install RefactoringIdioms

Running:

1). Default command is to save all refactored files for all Python Idioms in the current directory in ./RefactoringIdiomsOutputdir/. And it can get <non-idiomatic code, idiomatic code> code pairs for all Python files in the current directory for all Python idioms, and save these code pairs in result.json in the current directory:

 RIdiom

2). Options:

--filepath "your filepath" (e.g., main.py) is to refactor "your filepath" file. The default path is the current directory.

--idiom "IdiomName" (e.g., List Comprehension) is to refactor for the specified "IdiomName". Options are List Comprehension, Set Comprehension, Dict Comprehension, Chain Comparison, Truth Value Test, Assign Multiple Targets, For Multiple Targets, For Else, Star in Call, All. The default idiom is "All" that means all idioms.

--outputdir "your output folder" (e.g.,RefactoringIdiomsOutputdir/ ) is to save all refactored files in "your output folder". The default directory is "./RefactoringIdiomsOutputdir".

--output_codepair "your output path" (e.g.,result.json ) is to save all code pairs in "your output folder". The default path is "result.json".

--flag_merge_allcodepair (e.g., 1 ) means whether to store a separate file for each code pair. The values are 0 and 1. The 1 means refactor a file with all code pairs. The 0 means refactor a file with each code pair individually. The default value is 1.

For example, if you want to refactor code for a Python idiom in the given directory and save the refactored files in the given directory, you can execute the following command:

RIdiom --filepath "your filepath" --idiom "IdiomName" --outputdir "your output folder" --output_codepair  "your output path" --flag_merge_allcodepair 1

Web application:

We also develop a web application for the code refactoring, you could access the application through the url: 47.242.131.128:5000

Each time, you could click code area to refresh.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RefactoringIdioms-0.0.11.tar.gz (147.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

RefactoringIdioms-0.0.11-py3-none-any.whl (198.8 kB view details)

Uploaded Python 3

File details

Details for the file RefactoringIdioms-0.0.11.tar.gz.

File metadata

  • Download URL: RefactoringIdioms-0.0.11.tar.gz
  • Upload date:
  • Size: 147.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for RefactoringIdioms-0.0.11.tar.gz
Algorithm Hash digest
SHA256 b9658316ce57a4ec105775c0b9f874fdffd94b4670fd09c49fc00ac017280648
MD5 eba6cf595a00ac34ec31d8c3678a5689
BLAKE2b-256 02e7b4b96af56b052a69d473f7ba8f8013cf695e2d3a48b71d89e348999cf137

See more details on using hashes here.

File details

Details for the file RefactoringIdioms-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for RefactoringIdioms-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 bd01da4a9e8007c5f3740b56988675e19641c839192579118eac35776bedeb87
MD5 a35d6f489f1cc1d78b6c3bc24d4ffacf
BLAKE2b-256 92c8a3f9de3c060f6213dcf0dab4848102bda7ad9f37b05d764a03f92ad5a45f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page