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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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