Skip to main content

Toolkit for easy searching and manipulation of python source code using redbaron.

Project description

Toolkit for easy searching and manipulation of python source code using redbaron.

Codeship Status for Smirl/baroness

Installation

pip install baroness

See https://pypi.python.org/pypi/baroness

Usage

Searching

You can search through python code using the redbaron API on the commandline. By default baroness will search through all python files from the current directory down recursively. The search pattern is just regular python code that would work with redbaron. The top level node is called root.

For example to search for all name nodes with a value of bar:

baroness search 'root("name", value="bar")'

search is the default subcommand so you can write the same with:

baroness 'root("name", value="bar")'

For full usage look at baroness search --help:

usage: baroness search [-h] [--no-cache] [--parents PARENTS] [--no-color]
                       [--no-linenos]
                       pattern [files [files ...]]

positional arguments:
  pattern            Python redbaron code to search where `root` is the
                     variable holding the tree
  files              File names and/or glob pattern. Default to recursive
                     search of python all files.

optional arguments:
  -h, --help         show this help message and exit
  --no-cache         Do no use the cache in `.baroness` even if it exists
  --parents PARENTS  Number of parents to go up on matched nodes.
  --no-color         Do not color the output.
  --no-linenos       Do not output the linenumbers.

Caching

Parsing python files to a baron fst can be time consuming for large code bases. Baroness can cache the baron fst as json files to save time when searching. By default caching isn’t enabled, but will be used if baroness finds a .baroness directory.

Saving/Initialising Cache

To enable caching (and initially create cache) you can use:

baroness cache save

For full usage look at baroness cache save --help:

usage: baroness cache save [-h] [--force] [FILE [FILE ...]]

Save given files (all tree) to disk

positional arguments:
  FILE        Files to save to cache.

optional arguments:
  -h, --help  show this help message and exit
  --force     Save over already existing cache files.

Clearing the Cache

To delete all .baroness directories recursively use:

baroness cache delete

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baroness-1.1.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

baroness-1.1.3-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file baroness-1.1.3.tar.gz.

File metadata

  • Download URL: baroness-1.1.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for baroness-1.1.3.tar.gz
Algorithm Hash digest
SHA256 a799b728ee975cf742a04d408ec545d2d6faab87f600d6ba3dc1a80c0a000af3
MD5 ccf5da428a0802b8aa7f018bad9b64e1
BLAKE2b-256 1c6292def3fd71e1c6b9b6db3920b766df804587c4e05f90879209b0345899f1

See more details on using hashes here.

File details

Details for the file baroness-1.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for baroness-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 54816937cdd36f5dc1c1120f5b11b354e09e829c14e12ba6a9adf4703c41316f
MD5 83ec96794b5b83bfd57ae08c79399d2b
BLAKE2b-256 09e0bca296eea1a10da6f63462a61bbdd3c2602e364275545b043d680e04662b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page