Skip to content

Latest commit

 

History

History
121 lines (87 loc) · 4.01 KB

README.rst

File metadata and controls

121 lines (87 loc) · 4.01 KB

pypifs

https://codecov.io/github/moremoban/pypifs/coverage.png https://pepy.tech/badge/pypifs/month https://img.shields.io/github/stars/moremoban/pypifs.svg?style=social&maxAge=3600&label=Star https://dev.azure.com/moremoban/pypifs/_apis/build/status/moremoban.pypifs?branchName=master

It helps perform file operations over the python package. It installs the python package and returns python file system 2's OSFS instance.

The idea originates from moban, which uses python package as a vehicle to have versioned templates for the creation of a new python package. Surely, it can be implemented in any other ways but moban v0.6.0 mandates python file system 2 interface. Hence this library is written.

Get a file inside a python package

>>> import fs
>>> pypi_fs = fs.open_fs("pypi://pypi-mobans-pkg/resources/templates")
>>> pypi_fs.readtext("_version.py.jj2")
'__version__ = "0.0.2"\n__author__ = "C.W."\n'

List files of interest

>>> pypi_fs = fs.open_fs("pypi://pypi-mobans-pkg/resources")
>>> for path in pypi_fs.walk.files(filter=['*.jj2']):
...     print(path)
...
/templates/requirements.txt.jj2
/templates/installation.rst.jj2
/templates/test.script.jj2
/templates/conf.py.jj2
/templates/_version.py.jj2
/templates/Pipfile.jj2
/templates/min_requirements.txt.jj2
/templates/README.rst.jj2
/templates/badges.rst.jj2
/templates/__init__.py.jj2
/templates/NEW_BSD_LICENSE.jj2
/templates/MANIFEST.in.jj2
/templates/CHANGELOG.rst.jj2
/templates/travis.yml.jj2
/templates/setup.py.jj2
/templates/gitignore.jj2
/templates/lint.script.jj2
/templates/tests/requirements.txt.jj2
/templates/docs/make.bat.jj2
/templates/docs/Makefile.jj2
/templates/docs/index.rst.jj2
/templates/docs/source/conf.py.jj2
/templates/docs/source/index.rst.jj2

Does it write?

Yes, it will write as you can do so without using pypifs. But, it is never the intention of pypifs.

Primary use case

You can do the following with moban:

$ moban -t 'pypi://pypi-mobans-pkg/resources/templates/_version.py.jj2' \
        -c 'pypi://pypi-mobans-pkg/resources/config/data.yml' \
        -o _version.py
Collecting pypi-mobans-pkg
....
Installing collected packages: pypi-mobans-pkg
Successfully installed pypi-mobans-pkg-0.0.7
Templating pypi://pypi-mobans-pkg/resources/templates/_version.py.jj2 to _version.py
Templated 1 file.
$ cat _version.py
__version__ = "0.1.1rc3"
__author__ = "C.W."

Installation

You can install pypifs via pip:

$ pip install pypifs

or clone it and install it:

$ git clone https://github.com/moremoban/pypifs.git
$ cd pypifs
$ python setup.py install