Skip to main content

Ernest

What Ernest is

  1. A CLI-based tool for making bulk changes to files via Python, partly achieved through syntax trees (for .py files, using redbaron) and partly through regular expressions.
  2. Useful if you're making a load of really boring changes that you can't really do with regexes alone (or only with regexes the length of War and Peace).
  3. Named after the Nitpicker from The Adventure Zone.

It was made as part of a refactoring effort for a specific project and as such is pretty limited at the moment - it currently only contains methods for refactoring Python files but it is intended to be extensible.

What Ernest isn't

  1. A tool that will fix all your syntax problems.
  2. Pulling from any set of code standards - any new refactorings have to defined manually (though you can pick and choose which ones to apply).
  3. Particularly reliable.

Installation

pip install ernest

Configuration

You can override the defaults by making a JSON config file. By default Ernest looks in ~/.config/ernest/ernest.json but you can specify a different json file using the --config option.

{
  "name": "",  // the name of the project - used in headers
  "header": [  // added at the top of python files
    "#!/usr/bin/env python",
    "# encoding: utf-8",
    "This file is part of the {} project",  // example of how the name is used
    ""
  ],
  "imports": {  // checks python imports
    "exclude": [],  // do not allow these ever
    "conditional_exclude": {},  // do not allow these submodules from the main module, e.g. {'ernest': 'models'} excludes 'ernest.models' but allows 'ernest.helpers'
    "conditional_include": {}  // allow only these submodules from the main module, e.g. {'ernest': 'models'} allows 'ernest.models' but not 'ernest.helpers'
  }
}

You can find an example of the config file in the data folder.

Usage

Quickstart

ernest /project/path fix py

General Options

--config /path/to/config
--name "My Project"

Subcommands

stats

ernest [--config /path/to/config] [--name "My Project"] [/path/to/dir] stats [filetypes]

Show statistics for all files:

ernest /path/to/dir stats

Stats for just (e.g.) txt and md files:

ernest /path/to/dir stats txt md

fix

ernest [--config /path/to/config] [--name "My Project"] [/path/to/dir] fix [filetype] [fix(es)]

Run all fixes for .py files:

ernest /path/to/dir fix py all

Run the literal string quote and docstring quote fixes for .py files:

ernest /path/to/dir fix py literal docstring

Contributing

Please feel free to fork, submit pull requests, etc.! It doesn't have to be limited to Python files - that's just how Ernest processes the text.

Metadata

Release files for ernest 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ernest 0.1.6
File Size Uploaded Provenance
ernest-0.1.6.tar.gz 7.8 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for ernest 0.1.6
File
ernest-0.1.6-py3.7.egg Legacy Egg format - - Details
ernest-0.1.6-py3-none-any.whl Python 3 none any Details
ernest-0.1.6-py2.7.egg Legacy Egg format - - Details
ernest-0.1.6-py2-none-any.whl Python 2 none any Details

Total release size: 58.6 kB

Release files / ernest-0.1.6.tar.gz

Download URL ernest-0.1.6.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
53bef7a42d6c1ccfe0b746ddff84cc5c7505e54148da6f67756217445169a443
BLAKE2b-256 checksum
How to use checksums
f0f1461b4295421d2c52ca1de134b697024e7a74e359157e9a1a1cec9ae57073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / ernest-0.1.6-py3.7.egg

Download URL ernest-0.1.6-py3.7.egg
Size 11.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
5923d02e6073d331194c9d51e3d3b08b1e4ba68946609c343f9918eef954d7d3
BLAKE2b-256 checksum
How to use checksums
ff9fe775ae87e9d822c8c4e73d6cb174e5598103e9ee3c4484493cf4457b265e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / ernest-0.1.6-py3-none-any.whl

Download URL ernest-0.1.6-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3e5e6ae791b54f1404ca62fb6f080cdd7bf2a122aaf5be844c70f5acc7c04b3
BLAKE2b-256 checksum
How to use checksums
711b957d4f26ca61e819d6071271c06c8503071127a5d43615ff494f8e256ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / ernest-0.1.6-py2.7.egg

Download URL ernest-0.1.6-py2.7.egg
Size 11.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
ee3c768788a2f5bac50ff662be56ad199a42a52676e1c33a164b4ca390f02e94
BLAKE2b-256 checksum
How to use checksums
7a42f02feac615ee4a90322c973e8ec6757f48b4df7e444b0e80312e51979763
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / ernest-0.1.6-py2-none-any.whl

Download URL ernest-0.1.6-py2-none-any.whl
Size 13.5 kB
Tags Python 2
SHA-256 checksum
How to use checksums
958a09fcb19b12967e4e7e1883dd5487198a33d0d56e2d4f76c5a43d935de6c1
BLAKE2b-256 checksum
How to use checksums
3b0ec8da4c93aff85b83a64c69f81fc8f328c9981b9fe7af7a3f21a7a2ae0bbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Security for ernest 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.6 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page