Registry / serialization / pyjavaproperties

pyjavaproperties

JSON →
library0.7pypypi✓ verified 24d ago

This library, identified by the PyPI name `pyjavaproperties`, provides a Python 3 compatible replacement for Java's `java.util.Properties` class, enabling basic parsing and manipulation of Java Properties files. It is a fork of an ASPN recipe and aimed for cross-compatibility with Python 2 and Python 3. The project has not seen updates since early 2019.

pip install pyjavaproperties
INSTALL
IMPORT
SIG · PYJAVAPROPERTIES
P
pyjavaproperties
serializationpythonv0.7
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Properties
from pyjavaproperties import Properties

Demonstrates loading, accessing, modifying, and listing properties from a Java-style .properties file.

from pyjavaproperties import Properties import os # Create a dummy properties file for demonstration with open('test.properties', 'w') as f: f.write('name1=value1\n') f.write('name2=value2 with spaces\n') f.write('name3=another value\n') p = Properties() # Load properties from a file with open('test.properties', 'r') as f: p.load(f) print("Loaded properties:") p.list() # Access properties print(f"Value of name3: {p['name3']}") # Modify and add properties p['name3'] = 'changed = value' p['new key'] = 'new value with = sign' print("\nModified properties:") print(p) # To save properties to a file (optional) # with open('output.properties', 'w') as f: # p.store(f, 'Generated by pyjavaproperties') # Clean up dummy file os.remove('test.properties')
Debug
Known issues
breakingThe package name 'pyjavaproperties3' at version '0.6' as specified in the prompt does not appear to exist on PyPI. This entry refers to 'pyjavaproperties' version '0.7', which matches the provided summary and is the most likely intended package. Attempting to install `pyjavaproperties3` will fail.
fix
Use `pip install pyjavaproperties` and import `from pyjavaproperties import Properties`.
affects: All
gotchaThe library internally uses Python 2 string types, which means proper Unicode support is still missing and can lead to issues with non-ASCII characters in Python 3 environments.
fix
Be cautious with non-ASCII characters. Consider external encoding/decoding, or use an alternative library with robust Unicode support.
affects: 0.7 and earlier
gotchaThe project appears to be unmaintained. The last release on PyPI was in January 2019, indicating that there will be no further updates, bug fixes, or security patches.
fix
Evaluate the risk of using an unmaintained library for new projects. Consider migrating to a more actively developed alternative.
affects: 0.7 and earlier
gotchaFor new projects or if robust maintenance and full Unicode support are critical, consider the `javaproperties` library (e.g., `pip install javaproperties`), which offers a more actively maintained and feature-rich solution for handling Java .properties files.
fix
Research and potentially adopt `javaproperties` as an alternative.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyjavaproperties'
The `pyjavaproperties` package has not been installed or is not accessible in the current Python environment.
fix
Install the library using pip: `pip install pyjavaproperties`
FileNotFoundError: [Errno 2] No such file or directory: 'your_file.properties'
The properties file specified in the `load()` method does not exist at the given path or the path is incorrect.
fix
Ensure the properties file (`your_file.properties` in this example) exists and the path provided to `p.load(open('your_file.properties'))` is correct, including relative or absolute paths.
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position ... character maps to <undefined>
The library's internal use of Python 2 string types leads to issues with proper Unicode support when handling non-ASCII characters in properties files in a Python 3 environment, often resulting in encoding errors if the default system encoding is not compatible.
fix
Open the properties file with a specific encoding that matches the file's content (e.g., 'utf-8') before loading it: `p.load(open('your_file.properties', encoding='utf-8'))`.
AttributeError: 'Properties' object has no attribute 'get'
The `pyjavaproperties.Properties` object is designed to mimic `java.util.Properties` and does not implement all standard Python dictionary methods like `get()` directly; it supports direct dictionary-style access or `list()` and `items()`.
fix
Access properties using dictionary-style key lookup (`p['key']`) or iterate through items. If a default value is needed, use `p.get('key', default_value)` after ensuring the key exists, or use a `try-except KeyError` block. For robust handling of Java properties files, consider using the more actively maintained `javaproperties` library which offers a more complete dictionary-like interface.
Upgrade
Version history
0.7latest on PyPI · released Jan 25, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
10
Resources
pyjavaproperties — pip install pyjavaproperties · libregistry