-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
177 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/network_file_system | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build package | ||
run: python -m build | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.7"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install pytest | ||
python -m pip install -r requirements.txt | ||
python -m pip install . | ||
- name: Test with pytest | ||
run: | | ||
pytest . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,100 @@ | ||
Network-File-System | ||
=================== | ||
|BlackStyle| | ||
#################### | ||
rename_after_writing | ||
#################### | ||
|TestStatus| |PyPiStatus| |BlackStyle| |PackStyleBlack| | ||
|
||
A python-library to help with the completeness of files when moving, copying and writing. | ||
Writing a file is not atomic. In the worst case the process writing the file | ||
dies while the file is not yet complete. | ||
Also in some network-file-systems, the destination of a ``move`` or ``copy`` might show up before it is complete. | ||
Incomplete files are a potential risk for the integrity of your data. | ||
In the best case your reading process crashes, but in the worst case the incompleteness goes unnoticed. | ||
This package reduces the risk of having incomplete files by making all writing | ||
operations write to a temporary file in the destination's directory first before renaming it to its final destination. | ||
On most file-systems this final renamig is atomic. | ||
|
||
|
||
******* | ||
Install | ||
******* | ||
|
||
.. code-block:: | ||
pip install network_file_system | ||
********* | ||
Functions | ||
********* | ||
|
||
open | ||
==== | ||
|
||
Just like python's built in ``open()`` but when writing (``mode=w``) everything is writen | ||
to a temporary file in the destination's directory before the temporary file is renamed to the final destination. | ||
|
||
.. code-block:: python | ||
import network_file_system as nfs | ||
with nfs.open("my_file.txt", "wt") as f: | ||
for i in range(10): | ||
f.write(input()) | ||
copy | ||
==== | ||
|
||
Copies the file first to a temporary file in the destinations directory | ||
before moving it to its final path. | ||
|
||
|
||
.. code-block:: python | ||
import network_file_system as nfs | ||
nfs.copy(src="machine/with/src", dst="other/machine/in/network/dst") | ||
move | ||
==== | ||
|
||
Some implementations of network-file-systems might raise an | ||
``OSError`` with ``errno.EXDEV`` when an ``os.rename()`` is going across the | ||
boundary of a physical drive. | ||
In this case, this package's ``copy`` is used to copy the file beore unlinking | ||
the source-file. | ||
|
||
|
||
.. code-block:: python | ||
import network_file_system as nfs | ||
nfs.move(src="machine/with/src", dst="other/machine/in/network/dst") | ||
write | ||
===== | ||
|
||
When ``with open(...`` is too much. Writes to temporary file in targt's | ||
directory first before moving the temporary file to the target. | ||
|
||
.. code-block:: python | ||
import network_file_system as nfs | ||
nfs.write(content="My text.", path="another/machine/dst.txt", mode="wt") | ||
A python-library to make moves, copys and writes safer on remote drives. | ||
Writing a file is not atomic. In the worst case the process writing your file | ||
dies while the file is not complete. To at least spot such incomplete files, | ||
all writing-operations (write, move, copy, ...) will be followed by an | ||
atomic move. | ||
.. |BlackStyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg | ||
:target: https://github.com/psf/black | ||
:target: https://github.com/psf/black | ||
|
||
.. |TestStatus| image:: https://github.com/cherenkov-plenoscope/network_file_system/actions/workflows/test.yml/badge.svg?branch=main | ||
:target: https://github.com/cherenkov-plenoscope/network_file_system/actions/workflows/test.yml | ||
|
||
.. |PyPiStatus| image:: https://img.shields.io/pypi/v/network_file_system | ||
:target: https://pypi.org/project/network_file_system | ||
|
||
.. |PackStyleBlack| image:: https://img.shields.io/badge/pack%20style-black-000000.svg | ||
:target: https://github.com/cherenkov-plenoscope/black_pack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters