pyastrx


Namepyastrx JSON
Version 0.5.2 PyPI version JSON
download
home_pagehttps://github.com/pyastrx/pyastrx
Summary'Simple projects are all alike; each complexproject is complex in its own way.' - (adapted from Tolstoy's Anna Karenina)
upload_time2023-01-10 12:03:43
maintainer
docs_urlNone
authorBruno Messias
requires_python
licenseMIT
keywords ast xpath yaml linter parser refactoring tool vscode pyre pyre-linter
VCS
bugtrack_url
requirements colorama commonmark gast lxml prompt-toolkit pyaml pygments pyyaml rich typing-extensions wcwidth
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
================
What is PyASTrX?
================


Philosophy
==========


"Simple projects are all alike; each complex project is complex in its own way."
--------------------------------------------------------------------------------

(adapted from Tolstoy's Anna Karenina)


The PyASTrX philosophy is to provide a simple, easy-to-use, and
extensible framework for code quality analysis, refactoring and codebase analysis.

The main point that I've developed is that sometimes a necessary practice in one project can be a bad practice in another
project. In other words, we should **walk a **mile in **someone's** shoes** before judging the code quality of someone else code.

PyASTrX allows you to define new code analysis patterns using just XPATH
expressions. No need to write a parser, create a python file and ship to use in flake8 or pylint!


.. code-block:: bash

    pip install pyastrx


========
Features
========

PyASTrX provides the following features:

An easy customizable code quality analysis tool.
================================================

Type :code:`pyastrx -h` to see all the options.

You can also use a :code:`pyastrx.yaml` file to configure the tool.


Human-friendly
==============

Search and Linter outputs
-------------------------

If your codebase or pull request is huge, looking for possible
mistakes, bad practices or code smells can be a pain, so PyASTrX
provides a human-friendly output as default.

.. image:: _static/imgs/human_outputs.png
    :alt: Human-friendly outputs
    :align: center


Friendly interface
------------------

- autocomplete the previous queries
- combo box to select the files
- colorized syntax highlighting

.. image:: _static/imgs/interface.png
    :alt: Human friendly outputs
    :align: center

pre-commit
==========


Copy the `main.py` available at `pyastrx/.pre-commit-hook`_
in your folder and add the following entry in your `.pre-commit-config.yaml`.

.. _pyastrx/.pre-commit-hook: https://github.com/devmessias/pyastrx/blob/main/.pre-commit-hook/main.py

.. code-block:: yaml

    - repo: local
        hooks:
        - id: pyastrx
            name: PyASTrX linter
            entry: ./<LOCATION>/main.py
            language: script
            args: ["-q"]
            types: ["python"]
            description: Check for any violations using the pyastrx.yaml config
        - id: pyastrx-yaml
            name: PyASTrX linter
            entry: ./<LOCATION>/main.py
            language: script
            args: ["-q"]
            types: ["yaml"]
            description: Check for any violations using the pyastrx.yaml config

Later on, I will ship this to be used in the pre-commit channels.

VsCode extension
================


Soon, I will ship a VS Code extension.


Explore the AST and XML
=======================

Using the :code: `-i` arg or adding a :code: `interactive: true` in your
`pyastrx.yaml` you can explore the AST and XML parsed AST of your code.
This can be useful to understand your code base and helps you to write
you custom XPATH queries to be used in your project.


Folder exploration
------------------

**Start the interactive interface**

.. code:: console

    $ pyastrx -i -d path_to_folder (or just save that in yaml)

**Press f and choose a file**

.. image:: _static/imgs/ast_explorer2.png
    :alt: Interactive interface
    :align: center
    :width: 45%

**Choose the ast (t), xml (x) or code exploration (o)**

.. image:: _static/imgs/ast_explorer3.png
    :alt: Interactive interface
    :align: center
    :width: 45%

**Learn!**

.. image:: _static/imgs/ast_explorer4.png
    :alt: Interactive interface
    :align: center
    :width: 45%

.. image:: _static/imgs/ast_explorer5.png
    :alt: Interactive interface
    :align: center
    :width: 45%

File exploration (one key-press distance)
-----------------------------------------


**Open the interactive with the python file**

.. code:: console

    $ pyastrx -i -f path_to_file (or just save that in yaml)


**Choose the ast (t), xml (x) or code exploration (o)**

==========================
On the shoulders of giants
==========================


This project is possible only because of the work of several
developers across the following projects:


lxml
=====

One of the greatest Python libraries, downloaded over millions of time.
Please, consider doing a donation to the `lxml <https://lxml.de/>`_ developers.


astpath
=======

The PyASTrX started with the idea of using the astpath as a dependency, but I've
decided to rewrite and redesign it to improve the maintainability and the
usability features of PyASTrX. `astpath`_ is a great and simple tool
developed by `H. Chase Stevens`_.

.. _astpath: https://github.com/hchasestevens/astpath
.. _H. Chase Stevens: http://www.chasestevens.com/


GAST
====

`GAST`_ it's a remarkable tool developed by `Serge Sans Paille`_.
GAST allows you to use the same XPATH expressions to analyze different
code bases written in different python versions.


.. _Serge Sans Paille: http://serge.liyun.free.fr/serge/
.. _GAST: https://github.com/serge-sans-paille/gast



prompt_toolkit
==============

A project created by `Jonathan Slenders`_ that
 provides a powerful and reliable way to construct command-line interfaces.

This project has a lot of features, good documentation and the maintainers keep
it well updated.

.. _Jonathan Slenders: https://github.com/jonathanslenders
.. _prompt_toolkit: https://github.com/prompt-toolkit/



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyastrx/pyastrx",
    "name": "pyastrx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ast,xpath,yaml,linter,parser,refactoring tool,vscode,pyre,pyre-linter",
    "author": "Bruno Messias",
    "author_email": "devmessias@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "\n================\nWhat is PyASTrX?\n================\n\n\nPhilosophy\n==========\n\n\n\"Simple projects are all alike; each complex project is complex in its own way.\"\n--------------------------------------------------------------------------------\n\n(adapted from Tolstoy's Anna Karenina)\n\n\nThe PyASTrX philosophy is to provide a simple, easy-to-use, and\nextensible framework for code quality analysis, refactoring and codebase analysis.\n\nThe main point that I've developed is that sometimes a necessary practice in one project can be a bad practice in another\nproject. In other words, we should **walk a **mile in **someone's** shoes** before judging the code quality of someone else code.\n\nPyASTrX allows you to define new code analysis patterns using just XPATH\nexpressions. No need to write a parser, create a python file and ship to use in flake8 or pylint!\n\n\n.. code-block:: bash\n\n    pip install pyastrx\n\n\n========\nFeatures\n========\n\nPyASTrX provides the following features:\n\nAn easy customizable code quality analysis tool.\n================================================\n\nType :code:`pyastrx -h` to see all the options.\n\nYou can also use a :code:`pyastrx.yaml` file to configure the tool.\n\n\nHuman-friendly\n==============\n\nSearch and Linter outputs\n-------------------------\n\nIf your codebase or pull request is huge, looking for possible\nmistakes, bad practices or code smells can be a pain, so PyASTrX\nprovides a human-friendly output as default.\n\n.. image:: _static/imgs/human_outputs.png\n    :alt: Human-friendly outputs\n    :align: center\n\n\nFriendly interface\n------------------\n\n- autocomplete the previous queries\n- combo box to select the files\n- colorized syntax highlighting\n\n.. image:: _static/imgs/interface.png\n    :alt: Human friendly outputs\n    :align: center\n\npre-commit\n==========\n\n\nCopy the `main.py` available at `pyastrx/.pre-commit-hook`_\nin your folder and add the following entry in your `.pre-commit-config.yaml`.\n\n.. _pyastrx/.pre-commit-hook: https://github.com/devmessias/pyastrx/blob/main/.pre-commit-hook/main.py\n\n.. code-block:: yaml\n\n    - repo: local\n        hooks:\n        - id: pyastrx\n            name: PyASTrX linter\n            entry: ./<LOCATION>/main.py\n            language: script\n            args: [\"-q\"]\n            types: [\"python\"]\n            description: Check for any violations using the pyastrx.yaml config\n        - id: pyastrx-yaml\n            name: PyASTrX linter\n            entry: ./<LOCATION>/main.py\n            language: script\n            args: [\"-q\"]\n            types: [\"yaml\"]\n            description: Check for any violations using the pyastrx.yaml config\n\nLater on, I will ship this to be used in the pre-commit channels.\n\nVsCode extension\n================\n\n\nSoon, I will ship a VS Code extension.\n\n\nExplore the AST and XML\n=======================\n\nUsing the :code: `-i` arg or adding a :code: `interactive: true` in your\n`pyastrx.yaml` you can explore the AST and XML parsed AST of your code.\nThis can be useful to understand your code base and helps you to write\nyou custom XPATH queries to be used in your project.\n\n\nFolder exploration\n------------------\n\n**Start the interactive interface**\n\n.. code:: console\n\n    $ pyastrx -i -d path_to_folder (or just save that in yaml)\n\n**Press f and choose a file**\n\n.. image:: _static/imgs/ast_explorer2.png\n    :alt: Interactive interface\n    :align: center\n    :width: 45%\n\n**Choose the ast (t), xml (x) or code exploration (o)**\n\n.. image:: _static/imgs/ast_explorer3.png\n    :alt: Interactive interface\n    :align: center\n    :width: 45%\n\n**Learn!**\n\n.. image:: _static/imgs/ast_explorer4.png\n    :alt: Interactive interface\n    :align: center\n    :width: 45%\n\n.. image:: _static/imgs/ast_explorer5.png\n    :alt: Interactive interface\n    :align: center\n    :width: 45%\n\nFile exploration (one key-press distance)\n-----------------------------------------\n\n\n**Open the interactive with the python file**\n\n.. code:: console\n\n    $ pyastrx -i -f path_to_file (or just save that in yaml)\n\n\n**Choose the ast (t), xml (x) or code exploration (o)**\n\n==========================\nOn the shoulders of giants\n==========================\n\n\nThis project is possible only because of the work of several\ndevelopers across the following projects:\n\n\nlxml\n=====\n\nOne of the greatest Python libraries, downloaded over millions of time.\nPlease, consider doing a donation to the `lxml <https://lxml.de/>`_ developers.\n\n\nastpath\n=======\n\nThe PyASTrX started with the idea of using the astpath as a dependency, but I've\ndecided to rewrite and redesign it to improve the maintainability and the\nusability features of PyASTrX. `astpath`_ is a great and simple tool\ndeveloped by `H. Chase Stevens`_.\n\n.. _astpath: https://github.com/hchasestevens/astpath\n.. _H. Chase Stevens: http://www.chasestevens.com/\n\n\nGAST\n====\n\n`GAST`_ it's a remarkable tool developed by `Serge Sans Paille`_.\nGAST allows you to use the same XPATH expressions to analyze different\ncode bases written in different python versions.\n\n\n.. _Serge Sans Paille: http://serge.liyun.free.fr/serge/\n.. _GAST: https://github.com/serge-sans-paille/gast\n\n\n\nprompt_toolkit\n==============\n\nA project created by `Jonathan Slenders`_ that\n provides a powerful and reliable way to construct command-line interfaces.\n\nThis project has a lot of features, good documentation and the maintainers keep\nit well updated.\n\n.. _Jonathan Slenders: https://github.com/jonathanslenders\n.. _prompt_toolkit: https://github.com/prompt-toolkit/\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "'Simple projects are all alike; each complexproject is complex in its own way.' - (adapted from Tolstoy's Anna Karenina)",
    "version": "0.5.2",
    "split_keywords": [
        "ast",
        "xpath",
        "yaml",
        "linter",
        "parser",
        "refactoring tool",
        "vscode",
        "pyre",
        "pyre-linter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c90bdcecd44543d24c0c6dcf6b932838bffed716b5effc7609296ff32f7859d",
                "md5": "58327b09da4871d48f63790226bdfc01",
                "sha256": "c3cdfb6293e1733fce333d260c95a00b80dc55f1888f75be0fd15a34f49f15b6"
            },
            "downloads": -1,
            "filename": "pyastrx-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58327b09da4871d48f63790226bdfc01",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 41042,
            "upload_time": "2023-01-10T12:03:43",
            "upload_time_iso_8601": "2023-01-10T12:03:43.618991Z",
            "url": "https://files.pythonhosted.org/packages/3c/90/bdcecd44543d24c0c6dcf6b932838bffed716b5effc7609296ff32f7859d/pyastrx-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-10 12:03:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pyastrx",
    "github_project": "pyastrx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "colorama",
            "specs": [
                [
                    "==",
                    "0.4.4"
                ]
            ]
        },
        {
            "name": "commonmark",
            "specs": [
                [
                    "==",
                    "0.9.1"
                ]
            ]
        },
        {
            "name": "gast",
            "specs": [
                [
                    "==",
                    "0.5.3"
                ]
            ]
        },
        {
            "name": "lxml",
            "specs": [
                [
                    "==",
                    "4.9.1"
                ]
            ]
        },
        {
            "name": "prompt-toolkit",
            "specs": [
                [
                    "==",
                    "3.0.29"
                ]
            ]
        },
        {
            "name": "pyaml",
            "specs": [
                [
                    "==",
                    "21.10.1"
                ]
            ]
        },
        {
            "name": "pygments",
            "specs": [
                [
                    "==",
                    "2.12.0"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "12.4.1"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.4.0"
                ]
            ]
        },
        {
            "name": "wcwidth",
            "specs": [
                [
                    "==",
                    "0.2.5"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "pyastrx"
}
        
Elapsed time: 0.03109s