Skip to main content

Read files from python packages

Project description

https://api.travis-ci.org/moremoban/pypifs.svg https://codecov.io/github/moremoban/pypifs/coverage.png https://badge.fury.io/py/pypifs.svg 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.

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

Change log

0.0.2 - 13.5.2020

updated

  1. #8: suppress pip install std output

  2. #6: added license text in the package

0.0.1 - 18.8.2019

first release

  1. what a feat!

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

pypifs-0.0.2.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

pypifs-0.0.2-py2.py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 2 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