Git Product home page Git Product logo

pydiff's Introduction

python pydiff.py [--diffdoc] file1 file2

Compare Python scripts in syntax level, not in text level.
This tool can help you to find changes in code logic, ignoring
code style changes.

It does not compare docstrings by default.
Add --diffdoc option to compare docstrings as well.


Example usage:

        test_o.py
def foo(a, b):
    pass

if __name__ == '__main__':
    A = [1, 2, 3]
    print (4, 5, 6), \
          "over"
    foo(1, 2)
    print 'Hello World'


        test_n.py
def foo(a, b):
    pass

if __name__ == '__main__':
    A = [1,
         2, 3]
    print (4, 5, 6), "over"
    fooo(
         1, 2)
    print ('Hello '
           'World')


These two files are different, but some differences are just a matter of style.
The only significant difference is the function call "foo()" is misspelled in test_n.py.

Run pydiff.py, it will report:

$ python pydiff.py test_*.py
1 difference(s)
first file: test_n.py
second file: test_o.py

((8, 'fooo'), (8, 'foo'))

This report tells us the changes that might affect the logic of the code, and print related line numbers.
In fact pydiff parses the files into Abstract Syntax Tree, and compare the trees recursively.
It can also find insertions and deletions.



gitpydiff [commitID|branch or tag ref]

pydiff all .py and .py.in files in a git commit to it's parent commit.



install.sh

make symbol link /usr/bin/pydiff to pydiff.py and /usr/bin/gitpydiff to gitpydiff.

pydiff's People

Contributors

edwardbadboy avatar

Watchers

James Cloos avatar  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.