A python package for programmatically reading, writing, and managing Avid Media Composer bin access history logs (`.log` files).
Project description
pybinhistory
Because pybinlog was taken™
pybinhistory reads and writes .log access log files, which accompany .avb Avid bins. It includes data validation and convenience methods, such as the ability to "touch" a bin in one command.
In a multi-user Avid Media Composer environment, Avid will append an entry to a bin's log file each time a user writes to a bin. With pybinhistory, this functionality can be mimicked programmatically.
[!WARNING] While the
.loglog file format is a very simple one, it is officially undocumented. Use this library at your own risk -- I assume no responsibility for any damage to your project, loss of data, or reshoots being blatantly obvious in the final cut.
Quick Start
Touching A Bin
You can easily add an entry to the bin log with the BinLog.touch() convenience method.
from binlog import BinLog
# Write default entries containing the current datetime and user info
BinLog.touch("/path/to/bin.log") # Specify a .log path directly
BinLog.touch_bin("/path/to/bin.avb") # Specify a .avb path. This resolves the path to the same `bin.log` file
You can add custom entries by providing a BinLogEntry object:
from binlog import BinLog, BinLogEntry
my_cool_entry = BinLogEntry(user="me", computer="zAutomation")
BinLog.touch_bin("/path/to/bin.avb", my_cool_entry)
Getting The Most Recent Entry
You can obtain the most recent bin log entry with the BinLog.last_entry() method.
from binlog import BinLog
print(BinLog.from_bin("/path/to/bin.avb").last_entry())
This returns the most recent BinLogEntry item in the log:
BinLogEntry(timestamp=datetime.datetime(2023, 9, 22, 14, 8, 4), computer='zMichael', user='mj4u')
BinLog
A BinLog represents a... uh... bin log. It handles reading and writing to log files, and essentially encapsulates a list of BinLogEntrys.
Reading Bin Logs
A bin log can be read from a given file path with the class method BinLog.from_path()
from binlog import BinLog
log = BinLog.from_path("/path/to/bin.log")
Or, you can pass a text stream directly with the class method BinLog.from_path(). This can be helpful if you're dealing with a weird text encoding, or using something other than a typical file on disk.
from binlog import BinLog
with open("/path/to/bin.log", encoding="mac_roman", errors="replace") as log_handle:
log = BinLog.from_stream(log_handle)
[!NOTE] Unless specified by
BinLog.from_stream(encoding="somethin_else"),binhistoryclasses assume all.logfiles are UTF-8.In testing, this has worked quite well except for a single instance of a
mac_romancharacter from an ancient Avid project.
Writing Bin Logs
Similar to reading, BinLog can be written to a bin log with BinLog.to_path("/path/to/bin.log") or BinLog.to_stream(textio_stream).
Creating Bin Logs
Aside from reading a bin log from a file, a new BinLog can be created directly with BinLog(), optionally passing it a list of BinLogEntrys.
Accessing BinLogEntrys
To access the BinLogEntrys in a BinLog, the BinLog object can be directly iterated over; or a list of BinLogEntrys can be retrieved via the BinLog.entries property.
BinLogEntry
A BinLog contains a list of BinLogEntry objects. BinLogEntry is really just a python dataclass with the following fields:
timestamp[datetime]: Timestamp of accesscomputer[str]: Typically the hostname of the Avid that accessed the binuser[str]: The Avid user who accessed the bin
Formatting
Although BinLog typically handles reading and writing BinLogEntrys internally, BinLogEntry can be formatted as a typical log entry string with .to_string(), or read in from a log entry string with .from_string(str).
About Those Timestamps
It should be noted that a timestamp in a typical log entry file does not specify the year, but it does specify the name of the day of the week.
To derive a valid datetime.datetime object from this, binhistory methods that read existing log entries will resolve a valid year based on the file modified date of the .log file, working backwards until a valid day-of-the-week-name and month-day combo is found. This typically works quite well, but if file modified dates are wildly inaccurate (for instance, working with a very old project restored from an archive that didn't retain original file timestamps), the year
may be determined incorrectly.
Methods such as BinLog.from_path(), BinLog.from_bin(), and BinLogEntry.from_string() have an optional max_year:int argument for which you can provide the most recent year that should be considered when determining
the correct year of the timestamp.
See Also
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybinhistory-0.4.0.tar.gz.
File metadata
- Download URL: pybinhistory-0.4.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e40f73aec6597a13b7703b21dd40bbab0a5a15c9c2a84604663286d4bd96c1b1
|
|
| MD5 |
44986d9baab5fae11aa3d1bd2bca6fc3
|
|
| BLAKE2b-256 |
66daefb9dd74e733e28f7481c3b8faee4cc0042dfcded73a048eba4b0b42e6cd
|
Provenance
The following attestation bundles were made for pybinhistory-0.4.0.tar.gz:
Publisher:
pypi-publish.yml on mjiggidy/pybinhistory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybinhistory-0.4.0.tar.gz -
Subject digest:
e40f73aec6597a13b7703b21dd40bbab0a5a15c9c2a84604663286d4bd96c1b1 - Sigstore transparency entry: 174893108
- Sigstore integration time:
-
Permalink:
mjiggidy/pybinhistory@5fef6c9dd77d3f331b86beba881049654576780b -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mjiggidy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@5fef6c9dd77d3f331b86beba881049654576780b -
Trigger Event:
release
-
Statement type:
File details
Details for the file pybinhistory-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pybinhistory-0.4.0-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfe9b5c11c8e9fdc1d94c9369e59857e171f2a7a3ce00b9671f5816a081060d8
|
|
| MD5 |
4504d8219f1aa40461c69ac69ee8599f
|
|
| BLAKE2b-256 |
421319819d412fbe29b4f377272939334f94c7a4da0b4f0f374734d134fb97a8
|
Provenance
The following attestation bundles were made for pybinhistory-0.4.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on mjiggidy/pybinhistory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybinhistory-0.4.0-py3-none-any.whl -
Subject digest:
bfe9b5c11c8e9fdc1d94c9369e59857e171f2a7a3ce00b9671f5816a081060d8 - Sigstore transparency entry: 174893115
- Sigstore integration time:
-
Permalink:
mjiggidy/pybinhistory@5fef6c9dd77d3f331b86beba881049654576780b -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mjiggidy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@5fef6c9dd77d3f331b86beba881049654576780b -
Trigger Event:
release
-
Statement type: