howigothere


Namehowigothere JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryPython module to create a condensed stack preview
upload_time2024-03-03 21:44:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseNone
keywords debugging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HowIGotHere

A package containing a single function `howigothere` that returns a condensed
stack preview. Useful for debugging to easily trace how some call was made,
even through a jungle of calls made by frameworks and other packages.

To see it in action, you can run
[`example.py`](https://github.com/vsego/howigothere/blob/master/example.py) or,
if you didn't install the package but you only downloaded this repository,
`./try_me.sh example.py`. Both approaches require that
[`settings-collector`](https://pypi.org/project/settings-collector/) is
installed. The result should look like this:

![Screenshot](https://raw.githubusercontent.com/vsego/howigothere/master/images/example.png)

## Content

1. [The name](#the-name)
2. [Usage](#usage)
3. [Global setup](#global-setup)
4. [Local setup](#local-setup)

## The name

The name of the package is "How I Got Here?". If your question is "How I Go
There?", wherever "there" might be, you'll need to ask some other package.

## Usage

Make an import:
```python
from howigothere import howigothere
```
and then call
```python
print(howigothere())  # or logger.debug(howigothere())
```
somewhere in your code.

## Global setup

This package relies on
[`settings-collector`](https://pypi.org/project/settings-collector/) to collect
settings from various frameworks. This means that you can set it up through
standard mechanisms of the framework used by your project.

For example, if you are using Django, you can set the separator colour by
defining `HOWIGOTHERE__COLOR_SEP` (note two underscores before `COLOR`, but
only one after it) in your Django settings. The frameworks' settings character
casing is respected, so - for example - in TurboGears this will be
`howigothere__color_sep`

If you don't use a framework (or, at least, not one supported by
`settings-collector`), you can also use `sc_settings` (`settings-collector`'s
`dict`-like equivalent of frameworks' configs) and do something this:
```python
from settings_collector import sc_settings

sc_settings["howigothere__color_sep"] = colorama.Fore.RED
```

For more details, please see the documentation of `settings-collector`.

If the setup (either in `sc_settings` or in framework's settings) contains
`settings-collector`'s scopes, you can specify the scope to use like this:
```python
howigothere(namespace="some_scope")
```

## Local setup

Lastly, you can also configure values when calling the function. For example,
```python
howigothere(color_sep=colorama.Fore.RED)
```

Here is the list of all arguments accepted by the function. All but `namespace`
are also available in `sc_settings` and frameworks' settings. The default
values are as shown, unless overridden in `sc_settings` or framework's setup.

* `namespace` [default: `None`]: If set, it is used as scope identifier in
  `settings_collector`.
* `keep_dirs` [default: 1]: The number of directories to keep in output (`None`
  to keep them all). For example, if set to `2`, path `/a/b/c/d/e/f.py` will be
  displayed as `d/e/f.py`. This is to reduce the output while still being able
  to distinguish between files with the same name.
* `sep` [default: `" > "`]: Separator between calls.
* `call_format` [default: `"{function} ({path}:{lineno})"`]: The format of each
  call.
* `no_color` [default: `False`]: If set to `True`, colours won't be used even
  if they are properly defined. This is useful if you want to have properly
  coloured printouts most of the times, but you sometimes want to add these to
  some logging system that doesn't support your preferred way of colouring
  text.
* `start_from_dir` [default: `None`]: If set, output is suppressed until the
  first file having `start_from_dir` as its parent. This can also be a tuple of
  strings, in which case encountering any of them starts the output.

To add to those, colours can also be redefined. Their defaults depend on the
presence of `colorama` package (if it's not there, these are all empty strings
by default). The displayed defaults assume that `colorama` is installed and
that its `Fore` and `Style` constants are imported.

* `color_reset` [default: `Style.RESET_ALL`]: This is added to the end of each
  colourisable chunk (separator, function name, etc.).
* `color_sep` [default: `""`, i.e., no colouring]: The colour used for the
  separators between calls.
* `color_func`[ default: `Style.BRIGHT + Fore.GREEN`]: The colour used for
  functions' names in each call.
* `color_path` [default: `Style.BRIGHT + Fore.CYAN`]: The colour used for path
  of the each file containing called functions.
* `color_lineno` [default: `Fore.CYAN`]: The colour used for the line numbers
  where calls were made.

There is also support for showing arguments to calls in the stack, turned off
by default for backwards compatibility. The arguments controlling this are:

* `show_args` [default: `False`]: A switch determining if the arguments should
  be shown or not.
* `color_arg_name` [default: `Style.BRIGHT + Fore.BLUE`]: The colour used for
  arguments' names.
* `color_arg_eq` [default: `Style.BRIGHT + Fore.GREEN`]: The colour used for
  the equality sign between arguments' names and values.
* `color_arg_value` [default: `Style.BRIGHT + Fore.YELLOW`]: The colour used
  for arguments' values.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "howigothere",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "debugging",
    "author": null,
    "author_email": "Vedran Sego <vsego@vsego.org>",
    "download_url": "https://files.pythonhosted.org/packages/17/10/1c90ea0b91a8b4148af903afdaa9c2a44855507128388ee4b6cd852ec6ab/howigothere-1.1.0.tar.gz",
    "platform": null,
    "description": "# HowIGotHere\n\nA package containing a single function `howigothere` that returns a condensed\nstack preview. Useful for debugging to easily trace how some call was made,\neven through a jungle of calls made by frameworks and other packages.\n\nTo see it in action, you can run\n[`example.py`](https://github.com/vsego/howigothere/blob/master/example.py) or,\nif you didn't install the package but you only downloaded this repository,\n`./try_me.sh example.py`. Both approaches require that\n[`settings-collector`](https://pypi.org/project/settings-collector/) is\ninstalled. The result should look like this:\n\n![Screenshot](https://raw.githubusercontent.com/vsego/howigothere/master/images/example.png)\n\n## Content\n\n1. [The name](#the-name)\n2. [Usage](#usage)\n3. [Global setup](#global-setup)\n4. [Local setup](#local-setup)\n\n## The name\n\nThe name of the package is \"How I Got Here?\". If your question is \"How I Go\nThere?\", wherever \"there\" might be, you'll need to ask some other package.\n\n## Usage\n\nMake an import:\n```python\nfrom howigothere import howigothere\n```\nand then call\n```python\nprint(howigothere())  # or logger.debug(howigothere())\n```\nsomewhere in your code.\n\n## Global setup\n\nThis package relies on\n[`settings-collector`](https://pypi.org/project/settings-collector/) to collect\nsettings from various frameworks. This means that you can set it up through\nstandard mechanisms of the framework used by your project.\n\nFor example, if you are using Django, you can set the separator colour by\ndefining `HOWIGOTHERE__COLOR_SEP` (note two underscores before `COLOR`, but\nonly one after it) in your Django settings. The frameworks' settings character\ncasing is respected, so - for example - in TurboGears this will be\n`howigothere__color_sep`\n\nIf you don't use a framework (or, at least, not one supported by\n`settings-collector`), you can also use `sc_settings` (`settings-collector`'s\n`dict`-like equivalent of frameworks' configs) and do something this:\n```python\nfrom settings_collector import sc_settings\n\nsc_settings[\"howigothere__color_sep\"] = colorama.Fore.RED\n```\n\nFor more details, please see the documentation of `settings-collector`.\n\nIf the setup (either in `sc_settings` or in framework's settings) contains\n`settings-collector`'s scopes, you can specify the scope to use like this:\n```python\nhowigothere(namespace=\"some_scope\")\n```\n\n## Local setup\n\nLastly, you can also configure values when calling the function. For example,\n```python\nhowigothere(color_sep=colorama.Fore.RED)\n```\n\nHere is the list of all arguments accepted by the function. All but `namespace`\nare also available in `sc_settings` and frameworks' settings. The default\nvalues are as shown, unless overridden in `sc_settings` or framework's setup.\n\n* `namespace` [default: `None`]: If set, it is used as scope identifier in\n  `settings_collector`.\n* `keep_dirs` [default: 1]: The number of directories to keep in output (`None`\n  to keep them all). For example, if set to `2`, path `/a/b/c/d/e/f.py` will be\n  displayed as `d/e/f.py`. This is to reduce the output while still being able\n  to distinguish between files with the same name.\n* `sep` [default: `\" > \"`]: Separator between calls.\n* `call_format` [default: `\"{function} ({path}:{lineno})\"`]: The format of each\n  call.\n* `no_color` [default: `False`]: If set to `True`, colours won't be used even\n  if they are properly defined. This is useful if you want to have properly\n  coloured printouts most of the times, but you sometimes want to add these to\n  some logging system that doesn't support your preferred way of colouring\n  text.\n* `start_from_dir` [default: `None`]: If set, output is suppressed until the\n  first file having `start_from_dir` as its parent. This can also be a tuple of\n  strings, in which case encountering any of them starts the output.\n\nTo add to those, colours can also be redefined. Their defaults depend on the\npresence of `colorama` package (if it's not there, these are all empty strings\nby default). The displayed defaults assume that `colorama` is installed and\nthat its `Fore` and `Style` constants are imported.\n\n* `color_reset` [default: `Style.RESET_ALL`]: This is added to the end of each\n  colourisable chunk (separator, function name, etc.).\n* `color_sep` [default: `\"\"`, i.e., no colouring]: The colour used for the\n  separators between calls.\n* `color_func`[ default: `Style.BRIGHT + Fore.GREEN`]: The colour used for\n  functions' names in each call.\n* `color_path` [default: `Style.BRIGHT + Fore.CYAN`]: The colour used for path\n  of the each file containing called functions.\n* `color_lineno` [default: `Fore.CYAN`]: The colour used for the line numbers\n  where calls were made.\n\nThere is also support for showing arguments to calls in the stack, turned off\nby default for backwards compatibility. The arguments controlling this are:\n\n* `show_args` [default: `False`]: A switch determining if the arguments should\n  be shown or not.\n* `color_arg_name` [default: `Style.BRIGHT + Fore.BLUE`]: The colour used for\n  arguments' names.\n* `color_arg_eq` [default: `Style.BRIGHT + Fore.GREEN`]: The colour used for\n  the equality sign between arguments' names and values.\n* `color_arg_value` [default: `Style.BRIGHT + Fore.YELLOW`]: The colour used\n  for arguments' values.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python module to create a condensed stack preview",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/vsego/howigothere/issues",
        "Changelog": "https://github.com/vsego/howigothere/blob/master/CHANGELOG.md",
        "Homepage": "https://github.com/vsego/howigothere"
    },
    "split_keywords": [
        "debugging"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0c878e2a7da60f777de848a7305bc472ddd5c667eca538ca007c9660a4a52590",
                "md5": "aa86d6fc6923fae1b4ec602d6515be18",
                "sha256": "ee6ec0e4eec6b08b807f4572b024bfacb5f88aa1b53c144283532555fb36dde3"
            },
            "downloads": -1,
            "filename": "howigothere-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa86d6fc6923fae1b4ec602d6515be18",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6753,
            "upload_time": "2024-03-03T21:44:06",
            "upload_time_iso_8601": "2024-03-03T21:44:06.379602Z",
            "url": "https://files.pythonhosted.org/packages/0c/87/8e2a7da60f777de848a7305bc472ddd5c667eca538ca007c9660a4a52590/howigothere-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "17101c90ea0b91a8b4148af903afdaa9c2a44855507128388ee4b6cd852ec6ab",
                "md5": "7e6dd585634c579e5278e0b8a0920caf",
                "sha256": "9459e4a92594835d3e95c5f2c4dfb53dc528874e3b1d2e861038d784625eb129"
            },
            "downloads": -1,
            "filename": "howigothere-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7e6dd585634c579e5278e0b8a0920caf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 22776,
            "upload_time": "2024-03-03T21:44:08",
            "upload_time_iso_8601": "2024-03-03T21:44:08.657505Z",
            "url": "https://files.pythonhosted.org/packages/17/10/1c90ea0b91a8b4148af903afdaa9c2a44855507128388ee4b6cd852ec6ab/howigothere-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-03 21:44:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vsego",
    "github_project": "howigothere",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "howigothere"
}
        
Elapsed time: 0.22927s