8000 GitHub - ashirafj/python-identifier-anonymizer: A Python library to anonymize and normalize identifiers in Python source code.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ashirafj/python-identifier-anonymizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 < 9B10 /div>
 
 

Repository files navigation

Python Identifier Anonymizer

A Python library to anonymize and normalize identifiers in Python source code.

Installation

pip install git+https://github.com/ashirafj/python-identifier-anonymizer

Usage

import anonymizer

anonymized_code, identifiers_map = anonymizer.anonymize(code)

Example

You can refer to the example program, example.py

Original code

The following source code is the original (input) source code to be anonymized.

# get values
a, b = map(int, input().split())

# calculate the area and perimeter
area = a * b
perimeter = 2 * (a + b)

# output the result
print(area, perimeter)

Anonymized code

The following source code is the anonymized (output) source code.

Please note that it also normalizes (removes) some tokens, such as comments, white lines, and white spaces.

VAR00, VAR01 = map(int, input().split())
VAR02 = VAR00 * VAR01
VAR03 = 2 * (VAR00 + VAR01)
print(VAR02, VAR03)

Identifier Map

The identifier map of the anonymization is as follows. It maps anonymized identifiers to original identifiers.

Anonymized Original
VAR00 a
VAR01 b
VAR02 area
VAR03 perimeter

Acknowledgments

This project is inspired by pycodesuggest and replicated a part of the code. We are grateful to the authors for their work.

About

A Python library to anonymize and normalize identifiers in Python source code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0