Skip to main content
:Date: 2018-10-10
:Version: 0.0.1
:Authors:
- Mohammad Alghafli <thebsom@gmail.com>

File slice is a part of a file. This library allows you to open a binary file
and see only part of it. You specify the start and end of the file part you want
to see. Read and write operations will always start at the specified start
position and will never exceed the specified end position. Here is an example of
how to use it::

from fileslice import Slicer

#let's open a file for reading
r = open('example.png', 'br')

#create a slicer for the file
slicer = Slicer(r)

#the slicer behaves like a function. call it to create as many fileslices
#as you want
start = 5 #the beginning of our partial file is at 5
size = 95 #the size of the part is 95 bytes so our end is 99
fileslice = slicer (start, size) #this is a file like object

#now we have a fileslice file from byte 5 to byte 99.
#the initial partial file seek position is 0.
print(fileslice.read()) #will print from byte 5 to 99.

#now our seek position is at the end of the fileslice file
#that is byte 100 of the full file
try:
#if we seek to a position out of the fileslice file range (from 0 to 95)
fileslice.seek(200)
except ValueError:
#an exception will be thrown
print('error while seeking to 200')

#we can seek from the end of the fileslice or from current fileslice
#seek position
#let's seek to fifth byte from the end of the file. that is byte 95
fileslice.seek(-5, 2)

This library also works in writable files. Multiple threads can be used to read
and write to different file slices from the same file. Just make sure you do not
use the original opened file or the fileslices (and the original file object)
will be confused.

--------
Tutorial
--------
Check out fileslice tutorial at http://fileslice.readthedocs.io/

Release files for fileslice 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fileslice 0.0.1
File Size Uploaded
fileslice-0.0.1.tar.gz 7.7 kB Details

Release files / fileslice-0.0.1.tar.gz

Download URL fileslice-0.0.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d470cc4f8feee66f12b9cf0fd4e656cd7ca72077b2e4c3c0f672751cbdd92bcd
BLAKE2b-256 checksum
How to use checksums
2b346c900ee5eba39fb38e95e78a71f797017e05794a4b634d6225015c2822c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.10.0 pkginfo/1.2.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page