Metadata-Version: 2.1
Name: tc-pysh
Version: 0.4.2
Summary: Some utils for file manipulation scripts
Home-page: https://gitlab.com/Lattay/pysh
Author: Théo Cavignac
Author-email: theo.cavignac+dev@gmail.com
License: BSD 3-Clause License
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: BSD License
Classifier: Environment :: Console
Classifier: Topic :: Software Development :: User Interfaces
Description-Content-Type: text/markdown

# Pysh

## About

Pysh aims at providing the tools required to write in Python the script I would have written in bash before.

Python provide a more robust, and more powerful environment for scripting and makes the script easier to maintain and extend.
Pysh makes it possible to write file manipulation script just as quickly as in bash.

It should be good both for quick one-of scripts, as well as more complex reusable small programs.


## Usage

At the center of pysh is the path facilities: `pysh.AbsolutePath` and `pysh.RelativePath` are objects representing locations in the file system taht are easy to manipulate and use with pysh utils, as well as with most of python standard library thanks to `os.PathLike`.

`pysh.utils` provides equivalents of the commonly used commands in bash scripts such as `mv`, `cp`, `rm`, `cat`, etc.

`pysh.ls` and `pysh.find` provides familiar interface to the `pysh.query` facilities, making it easy to browse a directory or arborescence, with tools likes sorting and filtering in the form of iterators, building on top of the standard library and the `re` standard module.

`pysh.file` provides a set of functions that are related to file *content*, like `grep`, `head` and `tail`.

Here is an example of using `ls` to print the sizes of all text files of a directory.
```python
from pysh import ls
from pysh.file import size, human

for f in ls().name(r".*\.txt").sort():
    s = size(f) 
    s, u = human(s)

    print(str(f), s, u)
```
