Encode/decode Java's META-INF/MANIFEST.MF in Python
Likely abandoned. No release or commit for years (last release over 6 years ago).
pip install java-manifestjava-manifest-py
Encode/decode Java's META-INF/MANIFEST.MF in Python.
Installation
To install the latest release on PyPI, run:
$ pip install java-manifest
Usage
A MANIFEST is represented by a list of dictionaries, where each dictionary
corresponds to an empty-line delimited section of the MANIFEST and each
dictionary has str keys and either str or bool values.
java_manifest.loads takes a string containing MANIFEST-formatted data and
returns a list of dictionaries, where each dictionary is a section in the
MANIFEST. java_manifest.load does the same, using any typing.TextIO
readable object.
>>> import java_manifest
>>> manifest_str = """
... Name: README-Example-1
... Long-Line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
... aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
...
... Name: README-Example-2
... Foo: Bar
... """
>>> manifest = java_manifest.loads(manifest_str)
>>> print(manifest)
[{'Name': 'README-Example-1', 'Long-Line': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}, {'Name': 'README-Example-2', 'Foo': 'Bar'}]
Similarly, java_manifest.dumps returns a string of MANIFEST-formatted data
from a list of dictionaries, where each dictionary is a section in the
MANIFEST. java_manifest.dump does the same, writing into any typing.TextIO
writable object.
>>> import java_manifest
>>> manifest = [
... {
... "Name": "README-Example",
... "Some-Str": "Some random string",
... },
... ]
>>> manifest_str = java_manifest.dumps(manifest)
>>> print(manifest_str)
Name: README-Example
Some-Str: Some random string
<BLANKLINE>
There is also a from_jar function that finds the META-INF/MANIFEST.MF file
within the jar and java_manifest.loads that.
>>> import java_manifest
>>> manifest = java_manifest.from_jar("test_files/simple.jar")