Porter
Porter provides simple file operations.
License
MIT.
Installation
Using pip:
pip install porter
File management
Import porter:
import porter
Create a folder:
porter.mkdir('/foo/bar')
# The new directory 'bar' will be created.
Rename a file/directory:
porter.rename('/foo/bar.txt', 'file.txt')
>>> '/foo/file.txt'
porter.rename('/foo/bar', 'folder')
>>> '/foo/folder'
Remove a file/directory:
porter.remove('/foo/bar')
Copy a file/directory:
# Two ways same result
porter.copy('/foo/bar.txt', '/foo1/bar.txt')
porter.copy_to('/foo/bar.txt', '/foo1')
Move a file/directory:
# Two ways same result
porter.move('/foo/bar', '/foo1/bar')
>>> '/foo1/bar'
porter.move_to('/foo/bar', '/foo1')
>>> '/foo1/bar'
Ignore and force:
porter.mkdir('/foo/bar', ignore=True)
# If '/foo/bar' exists, porter will not create the folder and no error will occur.
# Ignore option can ONLY ignore the error of the existing destination file/directory.
porter.move('/foo/bar', '/foo1/bar', force=True)
# If '/foo1/bar' exists, porter will move the directory anyway.
Ignore and force are both available in ‘mkdir’, ‘copy’, ‘copy_to’, ‘move’, ‘move_to’ functions.
Archive:
porter.archive('/foo/bar')
>>> '/foo/bar.tar'
porter.archive('/foo/bar', 'archive', 'zip')
>>> '/foo/archive.zip'
porter.archive_to('/foo/bar', '/foo/bar1', 'archive')
>>> '/foo/bar1/archive.tar'
All supported archive types: ‘gztar’, ‘bztar’, ‘tar’, ‘zip’
class TargetFile:
bar = porter.TargetFile('/foo/bar.txt')
bar.src
>>> '/foo/bar.txt'
bar.name
>>> 'bar'
bar.ext
>>> 'txt'
bar.move_to('foo1')
bar.src
>>> '/foo1/bar.txt'
bar.remove()
# Then it will be removed.
class TargetDirectory:
"""
The structure of the directory:
- foo
- bar
- dir1
- f1.txt
- dir2
- f2.txt
- foo1
"""
bar = porter.TargetDirectory('/foo/bar')
bar.src
>>> '/foo/bar'
bar.list()
>>> {'dir1': {'f1.txt': None}, 'dir2': {'f2.txt': None}}
bar.files()
>>> ['f1.txt', 'f2.txt']
bar.directories()
>>> ['dir1', 'dir2']
bar.move_to('foo1')
bar.src
>>> '/foo1/bar'
bar.empty()
# All of the files in it will be removed
bar.remove()
# Then it will be removed.
Metadata
Release files for porter 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| porter-0.1.5.tar.gz | 4.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| porter-0.1.5-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 10.8 kB
Release files / porter-0.1.5.tar.gz
| Download URL | porter-0.1.5.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06e879bee63d13f4919cb7682eb58b299e4483c0c312a1f60a5abeb2f2785ea8
|
|
BLAKE2b-256 checksum How to use checksums |
b4e9a3b40a574aae27c2bd5504ef9129d5d822bd2b6888e53654f99cf565c194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / porter-0.1.5-py2.7.egg
| Download URL | porter-0.1.5-py2.7.egg |
|---|---|
| Size | 6.7 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
4500bc2e5c94b703f6d04d3026c552d1778817e4b308bcfbd628f464f22a687a
|
|
BLAKE2b-256 checksum How to use checksums |
e34acdfc43a80d26fdc93cc22dc62fe70125a7c11f7488d1643c582a5c54e8c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for porter 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.