xdev


Namexdev JSON
Version 1.5.3 PyPI version JSON
download
home_pagehttps://github.com/Erotemic/xdev
SummaryAn excellent developer tool for excellent developers
upload_time2024-09-24 02:40:05
maintainerNone
docs_urlNone
authorJon Crall
requires_python>=3.7
licenseApache 2
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Xdev - Excellent Developer
--------------------------

|GithubActions| |Codecov| |Pypi| |Downloads| |ReadTheDocs|


+------------------+------------------------------------------+
| Read the docs    | https://xdev.readthedocs.io              |
+------------------+------------------------------------------+
| Github           | https://github.com/Erotemic/xdev         |
+------------------+------------------------------------------+
| Pypi             | https://pypi.org/project/xdev            |
+------------------+------------------------------------------+

Xdev is an excellent developer tool for excellent developers.
It contains miscellaneous and/or interactive debugging tools.

This started as a project for myself to contain development related tools that
I wouldn't want to ship with a package itself (where as `ubelt
<https://github.com/Erotemic/ubelt>`_ contains the tools used in programs
themselves). I've polished it up over the years, and it's become a reasonably
useful package with tools I could see others making use of.


This is the CLI:

.. code::

    usage: xdev [-h] [--version] {info,codeblock,sed,find,tree,pint,pyfile,pyversion,editfile,format_quotes,freshpyenv,docstubs,available_package_versions,dirstats} ...

    The XDEV CLI

    A collection of excellent developer tools for excellent developers.

    options:
      -h, --help            show this help message and exit
      --version             show version number and exit (default: False)

    commands:
      {info,codeblock,sed,find,tree,pint,pyfile,pyversion,editfile,format_quotes,freshpyenv,docstubs,available_package_versions,dirstats}
                            specify a command to run
        info                Info about xdev
        codeblock           Remove indentation from text.
        sed                 Search and replace text in files
        find                Find matching files or paths in a directory.
        tree                List a directory like a tree
        pint (convert_unit)
                            Converts one type of unit to another via the pint library.
        pyfile (modpath)    Prints the path corresponding to a Python module.
        pyversion (modversion)
                            Detect and print the version of a Python module or package.
        editfile (edit)     Opens a file in your visual editor determined by the ``VISUAL``
        format_quotes       Use single quotes for code and double quotes for docs.
        freshpyenv          Create a fresh environment in a docker container to test a Python package.
        docstubs (doctypes)
                            Generate Typed Stubs from Docstrings (experimental)
        available_package_versions (availpkg)
                            Print a table of available versions of a python package on Pypi
        dirstats            Analysis for code in a repository


.. .... mkinit xdev

This is the top level API:

.. code:: python

    from xdev import algo
    from xdev import autojit
    from xdev import class_reloader
    from xdev import cli
    from xdev import desktop_interaction
    from xdev import embeding
    from xdev import format_quotes
    from xdev import interactive_iter
    from xdev import introspect
    from xdev import misc
    from xdev import patterns
    from xdev import profiler
    from xdev import regex_builder
    from xdev import search_replace
    from xdev import tracebacks
    from xdev import util
    from xdev import util_networkx
    from xdev import util_path

    from xdev.algo import (edit_distance, knapsack, knapsack_greedy, knapsack_ilp,
                           knapsack_iterative, knapsack_iterative_int,
                           knapsack_iterative_numpy, number_of_decimals,)
    from xdev.autojit import (import_module_from_pyx,)
    from xdev.class_reloader import (reload_class,)
    from xdev.desktop_interaction import (editfile, startfile, view_directory,)
    from xdev.embeding import (EmbedOnException, embed, embed_if_requested,
                               embed_on_exception, embed_on_exception_context,
                               fix_embed_globals,)
    from xdev.format_quotes import (DOUBLE_QUOTE, SINGLE_QUOTE,
                                    TRIPLE_DOUBLE_QUOTE, TRIPLE_SINGLE_QUOTE,
                                    format_quotes, format_quotes_in_file,
                                    format_quotes_in_text,)
    from xdev.interactive_iter import (InteractiveIter,)
    from xdev.introspect import (distext, get_func_kwargs, get_stack_frame,
                                 iter_object_tree, test_object_pickleability,)
    from xdev.misc import (byte_str, difftext, nested_type, quantum_random,
                           set_overlaps, textfind, tree_repr,)
    from xdev.patterns import (MultiPattern, Pattern, PatternBase, RE_Pattern,
                               our_extended_regex_compile,)
    from xdev.profiler import (IS_PROFILING, profile, profile_globals,
                               profile_now,)
    from xdev.regex_builder import (PythonRegexBuilder, RegexBuilder,
                                    VimRegexBuilder,)
    from xdev.search_replace import (GrepResult, find, grep, grepfile, greptext,
                                     sed, sedfile,)
    from xdev.tracebacks import (make_warnings_print_tracebacks,)
    from xdev.util import (bubbletext, conj_phrase, take_column,)
    from xdev.util_networkx import (AsciiDirectedGlyphs, AsciiUndirectedGlyphs,
                                    UtfDirectedGlyphs, UtfUndirectedGlyphs,
                                    generate_network_text, graph_str,
                                    write_network_text,)
    from xdev.util_path import (ChDir, sidecar_glob, tree,)

Remarks
-------

Perhaps I should just use `ipdb` but I often just like to directly embed with
IPython whenever I want:


.. code:: python

    import xdev
    xdev.embed()


Or wherever I want whenever there is an exception.

.. code:: python

    import xdev
    with xdev.embed_on_exception:
        some_code()


I don't feel like I need  `ipdb <https://github.com/gotcha/ipdb>`_'s other features.


I also like to


.. code:: python

    def func(a=1, b=2, c=3):
        """
        Example:
            >>> from this.module import *  # import contextual namespace
            >>> import xinspect
            >>> globals().update(xinspect.get_func_kwargs(func))  # populates globals with default kwarg value
            >>> print(a + b + c)
            6
        """

But I know these things are a little dirty.

But these aren't production practices. These are development tricks and life
hacks to make working faster.


Also see ``xinspect`` for things like ``autogen_imports``


.. code:: python

    >>> import ubelt as ub
    >>> source = ub.codeblock(
    >>>     '''
    >>>     p = os.path.dirname(join('a', 'b'))
    >>>     glob.glob(p)
    >>>     ''')
    >>> # Generate a list of lines to fix the name errors
    >>> lines = autogen_imports(source=source)
    >>> print(lines)
    ['import glob', 'from os.path import join', 'import os']


The CLI
-------

The xdev CLI is getting kinda nice, although it is a bit of a hodgepodge of
functionality (much like this library).

.. code::

   pip install xdev
   xdev --help


It contains functionality that I generally use when developing on my setup, but
I often find lacking in the setup of others.

For instance the `tree <https://en.wikipedia.org/wiki/Tree_(command)>`_ UNIX
command is amazing, but not everyone has it installed, and getting it via
``apt`` requires sudo privileges. Meanwhile xdev can be installed in user space
via pip, so this provides me with an easy way to get ``tree`` on someone's
system while helping them debug.

Other examples are ``sed``, ``find``, ``pyfile``, and ``pyversion``. Look at
the ``--help`` for more info on them.

The ``dirstats`` function is like a buffed up ``tree``. In addition to printing
the directory tree structure it inspects the contents of the tree and
summarizes things like: number of lines per type of file. For Python files it
breaks up the analysis into code-lines and docstring lines to give a better
sense of project complexity.


For repo maintence I use this package in conjunction with `xcookie
<https://github.com/Erotemic/xcookie>`_. I use xcookie to generate the package
structure and then xdev helps fill in the details. Specifically the
``availpkg`` and ``docstubs`` commands.


The ``availpkg`` command has been indispensable for me when writing
requirements.txt files. If you need to find good versions of a package ---
especially a binary one, e.g. numpy --- for different versions of Python and
would like the appropirate requirements.txt syntax to be generated for you,
take a look at ``availpkg``. It also provides an overview of what versions of a
package are available for what operating systems / CPU architectures.


The ``docstubs`` command is designed to turn google-style docstrings into
proper type annotation stubs.  It "works on my machine" and currently requires
a custom monkey patched mypy. See the code for details, it is possible to use,
but it is still very raw. I do think it can evolve into a tool.


.. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/github/Erotemic/xdev?branch=master&svg=True
   :target: https://ci.appveyor.com/project/Erotemic/xdev/branch/master
.. |Codecov| image:: https://codecov.io/github/Erotemic/xdev/badge.svg?branch=master&service=github
   :target: https://codecov.io/github/Erotemic/xdev?branch=master
.. |Pypi| image:: https://img.shields.io/pypi/v/xdev.svg
   :target: https://pypi.python.org/pypi/xdev
.. |Downloads| image:: https://img.shields.io/pypi/dm/xdev.svg
   :target: https://pypistats.org/packages/xdev
.. |ReadTheDocs| image:: https://readthedocs.org/projects/xdev/badge/?version=latest
    :target: http://xdev.readthedocs.io/en/latest/
.. |GithubActions| image:: https://github.com/Erotemic/xdev/actions/workflows/tests.yml/badge.svg?branch=main
    :target: https://github.com/Erotemic/xdev/actions?query=branch%3Amain

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Erotemic/xdev",
    "name": "xdev",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Jon Crall",
    "author_email": "erotemic@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/da/58/589205435260ac6920aaf1cabcc146d3cc9b808d03b279e8d4197d32cddd/xdev-1.5.3.tar.gz",
    "platform": null,
    "description": "Xdev - Excellent Developer\n--------------------------\n\n|GithubActions| |Codecov| |Pypi| |Downloads| |ReadTheDocs|\n\n\n+------------------+------------------------------------------+\n| Read the docs    | https://xdev.readthedocs.io              |\n+------------------+------------------------------------------+\n| Github           | https://github.com/Erotemic/xdev         |\n+------------------+------------------------------------------+\n| Pypi             | https://pypi.org/project/xdev            |\n+------------------+------------------------------------------+\n\nXdev is an excellent developer tool for excellent developers.\nIt contains miscellaneous and/or interactive debugging tools.\n\nThis started as a project for myself to contain development related tools that\nI wouldn't want to ship with a package itself (where as `ubelt\n<https://github.com/Erotemic/ubelt>`_ contains the tools used in programs\nthemselves). I've polished it up over the years, and it's become a reasonably\nuseful package with tools I could see others making use of.\n\n\nThis is the CLI:\n\n.. code::\n\n    usage: xdev [-h] [--version] {info,codeblock,sed,find,tree,pint,pyfile,pyversion,editfile,format_quotes,freshpyenv,docstubs,available_package_versions,dirstats} ...\n\n    The XDEV CLI\n\n    A collection of excellent developer tools for excellent developers.\n\n    options:\n      -h, --help            show this help message and exit\n      --version             show version number and exit (default: False)\n\n    commands:\n      {info,codeblock,sed,find,tree,pint,pyfile,pyversion,editfile,format_quotes,freshpyenv,docstubs,available_package_versions,dirstats}\n                            specify a command to run\n        info                Info about xdev\n        codeblock           Remove indentation from text.\n        sed                 Search and replace text in files\n        find                Find matching files or paths in a directory.\n        tree                List a directory like a tree\n        pint (convert_unit)\n                            Converts one type of unit to another via the pint library.\n        pyfile (modpath)    Prints the path corresponding to a Python module.\n        pyversion (modversion)\n                            Detect and print the version of a Python module or package.\n        editfile (edit)     Opens a file in your visual editor determined by the ``VISUAL``\n        format_quotes       Use single quotes for code and double quotes for docs.\n        freshpyenv          Create a fresh environment in a docker container to test a Python package.\n        docstubs (doctypes)\n                            Generate Typed Stubs from Docstrings (experimental)\n        available_package_versions (availpkg)\n                            Print a table of available versions of a python package on Pypi\n        dirstats            Analysis for code in a repository\n\n\n.. .... mkinit xdev\n\nThis is the top level API:\n\n.. code:: python\n\n    from xdev import algo\n    from xdev import autojit\n    from xdev import class_reloader\n    from xdev import cli\n    from xdev import desktop_interaction\n    from xdev import embeding\n    from xdev import format_quotes\n    from xdev import interactive_iter\n    from xdev import introspect\n    from xdev import misc\n    from xdev import patterns\n    from xdev import profiler\n    from xdev import regex_builder\n    from xdev import search_replace\n    from xdev import tracebacks\n    from xdev import util\n    from xdev import util_networkx\n    from xdev import util_path\n\n    from xdev.algo import (edit_distance, knapsack, knapsack_greedy, knapsack_ilp,\n                           knapsack_iterative, knapsack_iterative_int,\n                           knapsack_iterative_numpy, number_of_decimals,)\n    from xdev.autojit import (import_module_from_pyx,)\n    from xdev.class_reloader import (reload_class,)\n    from xdev.desktop_interaction import (editfile, startfile, view_directory,)\n    from xdev.embeding import (EmbedOnException, embed, embed_if_requested,\n                               embed_on_exception, embed_on_exception_context,\n                               fix_embed_globals,)\n    from xdev.format_quotes import (DOUBLE_QUOTE, SINGLE_QUOTE,\n                                    TRIPLE_DOUBLE_QUOTE, TRIPLE_SINGLE_QUOTE,\n                                    format_quotes, format_quotes_in_file,\n                                    format_quotes_in_text,)\n    from xdev.interactive_iter import (InteractiveIter,)\n    from xdev.introspect import (distext, get_func_kwargs, get_stack_frame,\n                                 iter_object_tree, test_object_pickleability,)\n    from xdev.misc import (byte_str, difftext, nested_type, quantum_random,\n                           set_overlaps, textfind, tree_repr,)\n    from xdev.patterns import (MultiPattern, Pattern, PatternBase, RE_Pattern,\n                               our_extended_regex_compile,)\n    from xdev.profiler import (IS_PROFILING, profile, profile_globals,\n                               profile_now,)\n    from xdev.regex_builder import (PythonRegexBuilder, RegexBuilder,\n                                    VimRegexBuilder,)\n    from xdev.search_replace import (GrepResult, find, grep, grepfile, greptext,\n                                     sed, sedfile,)\n    from xdev.tracebacks import (make_warnings_print_tracebacks,)\n    from xdev.util import (bubbletext, conj_phrase, take_column,)\n    from xdev.util_networkx import (AsciiDirectedGlyphs, AsciiUndirectedGlyphs,\n                                    UtfDirectedGlyphs, UtfUndirectedGlyphs,\n                                    generate_network_text, graph_str,\n                                    write_network_text,)\n    from xdev.util_path import (ChDir, sidecar_glob, tree,)\n\nRemarks\n-------\n\nPerhaps I should just use `ipdb` but I often just like to directly embed with\nIPython whenever I want:\n\n\n.. code:: python\n\n    import xdev\n    xdev.embed()\n\n\nOr wherever I want whenever there is an exception.\n\n.. code:: python\n\n    import xdev\n    with xdev.embed_on_exception:\n        some_code()\n\n\nI don't feel like I need  `ipdb <https://github.com/gotcha/ipdb>`_'s other features.\n\n\nI also like to\n\n\n.. code:: python\n\n    def func(a=1, b=2, c=3):\n        \"\"\"\n        Example:\n            >>> from this.module import *  # import contextual namespace\n            >>> import xinspect\n            >>> globals().update(xinspect.get_func_kwargs(func))  # populates globals with default kwarg value\n            >>> print(a + b + c)\n            6\n        \"\"\"\n\nBut I know these things are a little dirty.\n\nBut these aren't production practices. These are development tricks and life\nhacks to make working faster.\n\n\nAlso see ``xinspect`` for things like ``autogen_imports``\n\n\n.. code:: python\n\n    >>> import ubelt as ub\n    >>> source = ub.codeblock(\n    >>>     '''\n    >>>     p = os.path.dirname(join('a', 'b'))\n    >>>     glob.glob(p)\n    >>>     ''')\n    >>> # Generate a list of lines to fix the name errors\n    >>> lines = autogen_imports(source=source)\n    >>> print(lines)\n    ['import glob', 'from os.path import join', 'import os']\n\n\nThe CLI\n-------\n\nThe xdev CLI is getting kinda nice, although it is a bit of a hodgepodge of\nfunctionality (much like this library).\n\n.. code::\n\n   pip install xdev\n   xdev --help\n\n\nIt contains functionality that I generally use when developing on my setup, but\nI often find lacking in the setup of others.\n\nFor instance the `tree <https://en.wikipedia.org/wiki/Tree_(command)>`_ UNIX\ncommand is amazing, but not everyone has it installed, and getting it via\n``apt`` requires sudo privileges. Meanwhile xdev can be installed in user space\nvia pip, so this provides me with an easy way to get ``tree`` on someone's\nsystem while helping them debug.\n\nOther examples are ``sed``, ``find``, ``pyfile``, and ``pyversion``. Look at\nthe ``--help`` for more info on them.\n\nThe ``dirstats`` function is like a buffed up ``tree``. In addition to printing\nthe directory tree structure it inspects the contents of the tree and\nsummarizes things like: number of lines per type of file. For Python files it\nbreaks up the analysis into code-lines and docstring lines to give a better\nsense of project complexity.\n\n\nFor repo maintence I use this package in conjunction with `xcookie\n<https://github.com/Erotemic/xcookie>`_. I use xcookie to generate the package\nstructure and then xdev helps fill in the details. Specifically the\n``availpkg`` and ``docstubs`` commands.\n\n\nThe ``availpkg`` command has been indispensable for me when writing\nrequirements.txt files. If you need to find good versions of a package ---\nespecially a binary one, e.g. numpy --- for different versions of Python and\nwould like the appropirate requirements.txt syntax to be generated for you,\ntake a look at ``availpkg``. It also provides an overview of what versions of a\npackage are available for what operating systems / CPU architectures.\n\n\nThe ``docstubs`` command is designed to turn google-style docstrings into\nproper type annotation stubs.  It \"works on my machine\" and currently requires\na custom monkey patched mypy. See the code for details, it is possible to use,\nbut it is still very raw. I do think it can evolve into a tool.\n\n\n.. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/github/Erotemic/xdev?branch=master&svg=True\n   :target: https://ci.appveyor.com/project/Erotemic/xdev/branch/master\n.. |Codecov| image:: https://codecov.io/github/Erotemic/xdev/badge.svg?branch=master&service=github\n   :target: https://codecov.io/github/Erotemic/xdev?branch=master\n.. |Pypi| image:: https://img.shields.io/pypi/v/xdev.svg\n   :target: https://pypi.python.org/pypi/xdev\n.. |Downloads| image:: https://img.shields.io/pypi/dm/xdev.svg\n   :target: https://pypistats.org/packages/xdev\n.. |ReadTheDocs| image:: https://readthedocs.org/projects/xdev/badge/?version=latest\n    :target: http://xdev.readthedocs.io/en/latest/\n.. |GithubActions| image:: https://github.com/Erotemic/xdev/actions/workflows/tests.yml/badge.svg?branch=main\n    :target: https://github.com/Erotemic/xdev/actions?query=branch%3Amain\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "An excellent developer tool for excellent developers",
    "version": "1.5.3",
    "project_urls": {
        "Homepage": "https://github.com/Erotemic/xdev"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "704a58d0b0e4cc45d0ae8f31a303d71e75c84cb6a2a3181bd2944afd3df45072",
                "md5": "e6dc2500236434b0f0485cba20af46c9",
                "sha256": "f3b19209f0622c36b63d9fd56e146607d2a82a852c384f577ceb102ebdcccb4b"
            },
            "downloads": -1,
            "filename": "xdev-1.5.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6dc2500236434b0f0485cba20af46c9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 127225,
            "upload_time": "2024-09-24T02:40:04",
            "upload_time_iso_8601": "2024-09-24T02:40:04.122739Z",
            "url": "https://files.pythonhosted.org/packages/70/4a/58d0b0e4cc45d0ae8f31a303d71e75c84cb6a2a3181bd2944afd3df45072/xdev-1.5.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da58589205435260ac6920aaf1cabcc146d3cc9b808d03b279e8d4197d32cddd",
                "md5": "7108bfe6e17bf1d56bf34d5a4b304cf6",
                "sha256": "2ccdf6601e698637b76355c2e675b45ff8002bd4f359005f0c6484369faf2445"
            },
            "downloads": -1,
            "filename": "xdev-1.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7108bfe6e17bf1d56bf34d5a4b304cf6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 122343,
            "upload_time": "2024-09-24T02:40:05",
            "upload_time_iso_8601": "2024-09-24T02:40:05.919534Z",
            "url": "https://files.pythonhosted.org/packages/da/58/589205435260ac6920aaf1cabcc146d3cc9b808d03b279e8d4197d32cddd/xdev-1.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 02:40:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Erotemic",
    "github_project": "xdev",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "appveyor": true,
    "requirements": [],
    "lcname": "xdev"
}
        
Elapsed time: 3.90635s