Skip to main content

libraries to make it easier to maniuplate files in a directory tree

Project description

treecrawl

https://img.shields.io/pypi/v/treecrawl.svg https://img.shields.io/travis/natemarks/treecrawl.svg Documentation Status

libraries to make it easier to maniuplate files in a directory tree

Usage

This project makes it easier to edit directory trees and to test those edits.

** CAUTION!! ** treecrawl doesn’t protect you from mistreating your files by, for example, corrupting a binary file because you transformed it like a text file. In fact, utility.file_to_string() encodes binary to utf-8 ignoring errors, so it will help you wreck your files.

I generally manage this with scalpel-like opt-in targeting when I override Transformer.is_target(). I use extensions where it’s adequate, but if I need something more robust, I might use python-magic.

Check out the example transformer in tests.test_casehelper.MakeUpper

The example Transformer sub-class (MakeUpper) is a trivial example for using the Transformer class. remember the following tips: Always override Transformer.transform Override Transformer.is_target to customize the target file selection Almost always create and use an alternative to Transformer.write_string_to_output(). Treating everything like a string will cause SERIOUS problems with editing and testing with any unicode at all.

tests/test_casehelper.py::test_make_upper is a good example of the boilerplate use of casehelper. Also be sure to replicate the tests/conftest.py so you can capture the pytest –update_golden flag.

When you init CaseHelper with the update golden flag (by running pytest –update_golden), it deletes the golden directory and delays the copying of temp files until CaseHelper.compare() is run. In between these events, use the funciton under test to generate new project golden data

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Build Notes

Setup dev venv

python -m venv .treecrawl.venv
source .treecrawl.venv/bin/activate
pip install -r requirements-dev.txt

Tests

I use pyenv to provide multiple versions for nox python testing. in my case:

pyenv install 3.6.8
pyenv install 3.7.8
# in the project directory
pyenv local 3.6.8 3.7.8
make test

If other versions are flagged as missing or are skipped you can just pyenv instal them and add them to the project directory

run ‘make test’ to run all the tests. I use pyenv to install all of the supported python versions so nox can run the full matrix of tests for me

always run ‘ make lint’

History

0.1.3 (2020-07-17)

  • First release on PyPI.

0.1.4 (2020-07-17)

  • Reorganized modules and updateed documentation

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

treecrawl-0.1.22.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

treecrawl-0.1.22-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file treecrawl-0.1.22.tar.gz.

File metadata

  • Download URL: treecrawl-0.1.22.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for treecrawl-0.1.22.tar.gz
Algorithm Hash digest
SHA256 387ab675dbe1df04df99cccc21dde2222843fff0c18d7ea0d6428aab3b377901
MD5 0cad080c9d207d37a1801f5c7c5ac0de
BLAKE2b-256 05569f4175f3a693bf7c45b52bce449b610d03156637606bc46eef14e3a88635

See more details on using hashes here.

File details

Details for the file treecrawl-0.1.22-py3-none-any.whl.

File metadata

  • Download URL: treecrawl-0.1.22-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for treecrawl-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 30b48a203d9c9c4403f4c37ba144b4e9b92066c726dd142e9c475ea0e6ad3c63
MD5 4cd198fa6e6a636cb794ecc73eaeecef
BLAKE2b-256 89450b49fee85d33cf173bea23aa7c4e18b96be109156b724fa7e44c7a174c61

See more details on using hashes here.

Supported by

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