======
tailhead
======
Python tail is a simple implementation of GNU tail and head.
It provides 3 main functions that can be performed on any file-like object that supports ``seek()`` and ``tell()``.
* ``tail`` - read lines from the end of a file
* ``head`` - read lines from the top of a file
* ``follow`` - read lines as a file grows
It also comes with ``pytail``, a command line version offering the same functionality as GNU tail. This can be particularly useful on Windows systems that have no tail equivalent.
- `tailhead on GitHub <tailhead>`_
- `tailhead on Pypi <http://pypi.python.org/pypi/tailhead>`_
Installation
============
Install with ``pip`` or ``easy_install``.
::
pip install tailhead
Examples
========
::
import tailhead
f = open('test.txt', 'w')
for i in range(11):
f.write('Line %d\\n' % (i + 1))
f.close()
Tail
----
::
# Get the last 3 lines of the file
tailhead.tail(open('test.txt'), 3)
# ['Line 9', 'Line 10', 'Line 11']
Head
----
::
# Get the first 3 lines of the file
tailhead.head(open('test.txt'), 3)
# ['Line 1', 'Line 2', 'Line 3']
Follow
------
::
# Follow the file as it grows
for line in tailhead.follow_path('test.txt'):
if line is not None:
print(line)
else:
# sleep
Running Tests
=============
Tailer currently only has doctests.
Run tests with nose::
nosetests --with-doctest tailhead
Run tests with doctest::
python -m doctest -v tailhead/__init__.py
Metadata
Release files for tailhead 1.0.2
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 | |
|---|---|---|---|---|
| tailhead-1.0.2.tar.gz | 7.5 kB | Without provenance | Details |
Release files / tailhead-1.0.2.tar.gz
| Download URL | tailhead-1.0.2.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
916f70583494f38009410f178c3aea3f3b5e3f3b9c2d83f643547b2651147a03
|
|
BLAKE2b-256 checksum How to use checksums |
17efd07d5a05e490f1b2ef7e5914e61ea222165ae76356a701551a1fd24b1dfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tailhead 1.0.2
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.