pyastrx


Namepyastrx JSON
Version 0.6.0 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_time2024-09-25 18:27:39
maintainerNone
docs_urlNone
authorBruno Messias
requires_pythonNone
licenseMIT
keywords ast xpath yaml linter parser refactoring tool vscode pyre pyre-linter
VCS
bugtrack_url
requirements colorama gast lxml prompt-toolkit pygments pyyaml rich typing-extensions watchdog 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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "ast, xpath, yaml, linter, parser, refactoring tool, vscode, pyre, pyre-linter",
    "author": "Bruno Messias",
    "author_email": "devmessias@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/56/62/c5c0023ce7d773de8a486235fa82aa673a369d215f2d8a2b4d727d6d91fe/pyastrx-0.6.0.tar.gz",
    "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",
    "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.6.0",
    "project_urls": {
        "Homepage": "https://github.com/pyastrx/pyastrx"
    },
    "split_keywords": [
        "ast",
        " xpath",
        " yaml",
        " linter",
        " parser",
        " refactoring tool",
        " vscode",
        " pyre",
        " pyre-linter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c31e51ae16052240f3dd7ed92b2d53dcb61e8c68067c649994e14de1ddf94ff",
                "md5": "56d3fb4310d94ea258db8d03f43bf494",
                "sha256": "be7ef4a05b3c526fba6759550d218c4c2d180b4267f5d2f74fd890c628b1d251"
            },
            "downloads": -1,
            "filename": "pyastrx-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "56d3fb4310d94ea258db8d03f43bf494",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 39678,
            "upload_time": "2024-09-25T18:27:37",
            "upload_time_iso_8601": "2024-09-25T18:27:37.891244Z",
            "url": "https://files.pythonhosted.org/packages/1c/31/e51ae16052240f3dd7ed92b2d53dcb61e8c68067c649994e14de1ddf94ff/pyastrx-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5662c5c0023ce7d773de8a486235fa82aa673a369d215f2d8a2b4d727d6d91fe",
                "md5": "b13f4822752a4992727982b6838050c6",
                "sha256": "c2832e504910d7578b863f3cd20a81f681a350674524cb156b417f6cd69b5cb1"
            },
            "downloads": -1,
            "filename": "pyastrx-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b13f4822752a4992727982b6838050c6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 35150,
            "upload_time": "2024-09-25T18:27:39",
            "upload_time_iso_8601": "2024-09-25T18:27:39.253546Z",
            "url": "https://files.pythonhosted.org/packages/56/62/c5c0023ce7d773de8a486235fa82aa673a369d215f2d8a2b4d727d6d91fe/pyastrx-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-25 18:27:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyastrx",
    "github_project": "pyastrx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "colorama",
            "specs": [
                [
                    "==",
                    "0.4.6"
                ]
            ]
        },
        {
            "name": "gast",
            "specs": [
                [
                    "==",
                    "0.6.0"
                ]
            ]
        },
        {
            "name": "lxml",
            "specs": [
                [
                    "==",
                    "5.3.0"
                ]
            ]
        },
        {
            "name": "prompt-toolkit",
            "specs": [
                [
                    "==",
                    "3.0.47"
                ]
            ]
        },
        {
            "name": "pygments",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        },
        {
            "name": "watchdog",
            "specs": []
        },
        {
            "name": "wcwidth",
            "specs": [
                [
                    "==",
                    "0.2.13"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "pyastrx"
}
        
Elapsed time: 0.42404s