Registry / serialization / java-manifest

java-manifest

JSON →
library1.1.0pypypi✓ verified 84d ago

The `java-manifest` library provides functionality to encode and decode Java's `META-INF/MANIFEST.MF` files using Python. It represents a manifest as a list of dictionaries, where each dictionary corresponds to a section within the manifest. The library is currently at version 1.1.0, with its last release in July 2020, indicating a low release cadence.

pip install java-manifest
INSTALL
IMPORT
SIG · JAVA-MANIFEST
J
java-manifest
serializationpythonv1.1.0
Install
1.5s avg
Import
32ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.035s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.030s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

java_manifest
import java_manifest
The primary module is imported as `java_manifest`, and its functions are then accessed via `java_manifest.loads()`, `java_manifest.dumps()`, etc.

Demonstrates loading a Java manifest string into a Python list of dictionaries, modifying it, and then dumping it back to a manifest-formatted string.

import java_manifest manifest_str = """Manifest-Version: 1.0 Created-By: My Build Tool Application-Name: ExampleApp Name: com/example/app/MainClass.class MD5-Digest: AB12CD34EF56GH78IJ90KL12MN34OP56 """ # Load manifest from a string manifest_data = java_manifest.loads(manifest_str) print("Loaded Manifest Data:") for section in manifest_data: print(section) # Add a new attribute to the first section if manifest_data: manifest_data[0]["New-Attribute"] = "SomeValue" # Dump manifest back to a string updated_manifest_str = java_manifest.dumps(manifest_data) print("\nUpdated Manifest String:") print(updated_manifest_str)
Debug
Known issues
gotchaJava manifest files, by specification, must end with a newline character. If the input manifest string or file lacks a trailing newline, the last attribute-value pair might be silently dropped or parsed incorrectly by this library or Java tools.
fix
Always ensure your manifest strings or files terminate with a newline character (e.g., `"Key: Value\n"` for a single line, or a final `\n` after the last entry for multi-line manifests).
affects: All versions
gotchaThe Java manifest format strictly treats all attribute values as strings. While the library supports `str` and `bool` values in the Python representation, attempting to dump manifests with other structured data types (e.g., lists, dictionaries, integers) for values will fail without custom handling.
fix
For complex or non-string values, provide custom `encoder` and `decoder` functions to `java_manifest.dumps()` and `java_manifest.loads()` respectively, to convert between Python objects and string representations as needed. The default behavior expects string or boolean values.
affects: All versions
Errors
Common errors & fixes
The last line of my manifest data is missing or incorrectly parsed after loading.
The input manifest string or file does not end with a newline character, which is required by the Java manifest specification for proper parsing of the final entry.
fix
Ensure that the manifest string or file you are processing or creating explicitly ends with a newline character (`\n`).
TypeError: ... object is not iterable (or similar type error) when dumping data.
You are attempting to dump a manifest where a value in one of the dictionary sections is not a `str` or `bool` type, and no custom `encoder` function has been provided to handle the conversion. The `java-manifest` library expects attribute values to be strings or booleans.
fix
Before dumping, convert all non-string/non-boolean values in your manifest data (list of dictionaries) to their string representations, or provide a custom `encoder` function to `java_manifest.dumps()` that handles the specific data types you are using.
Upgrade
Version history
1.1.0latest on PyPI · released Jul 22, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
java-manifest — pip install java-manifest · libregistry