All Projects → jwodder → javaproperties

jwodder / javaproperties

Licence: MIT license
Python library for reading & writing Java .properties files

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to javaproperties

goconfig
.gitconfig syntax parser
Stars: ✭ 15 (-25%)
Mutual labels:  config, configuration, properties
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+1025%)
Mutual labels:  config, configuration, properties
profig
Powerful configuration management for Scala (JSON, properties, command-line arguments, and environment variables)
Stars: ✭ 25 (+25%)
Mutual labels:  config, configuration, properties
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+630%)
Mutual labels:  config, configuration
Surfingkeys Conf
A SurfingKeys configuration which adds 130+ key mappings for 20+ sites & OmniBar search suggestions for 50+ sites
Stars: ✭ 137 (+585%)
Mutual labels:  config, configuration
Config
Manage Laravel configuration by persistent storage
Stars: ✭ 139 (+595%)
Mutual labels:  config, configuration
Config
A lightweight yet powerful config package for Go projects
Stars: ✭ 126 (+530%)
Mutual labels:  config, configuration
Config
Various program configuration files and scripts
Stars: ✭ 173 (+765%)
Mutual labels:  config, configuration
Magento2 Configurator
Magento 2 Configurator
Stars: ✭ 158 (+690%)
Mutual labels:  config, configuration
Aconfig
Simple, useful and opinionated config loader.
Stars: ✭ 187 (+835%)
Mutual labels:  config, configuration
Environ Config
Python Application Configuration With Environment Variables
Stars: ✭ 210 (+950%)
Mutual labels:  config, configuration
Winton.extensions.configuration.consul
Enables Consul to be used as a configuration source in dotnet core applications
Stars: ✭ 239 (+1095%)
Mutual labels:  config, configuration
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+9175%)
Mutual labels:  config, configuration
Ngx Config
Configuration utility for Angular
Stars: ✭ 135 (+575%)
Mutual labels:  config, configuration
Config
Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects.
Stars: ✭ 1,821 (+9005%)
Mutual labels:  config, configuration
Confl
Config parser for go, modeled after Nginx format, Nice lenient syntax with Comments
Stars: ✭ 127 (+535%)
Mutual labels:  config, configuration
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+725%)
Mutual labels:  config, configuration
dotfiles
Linux configuration files (dotfiles) and some useful scripts
Stars: ✭ 22 (+10%)
Mutual labels:  config, configuration
Appconfiguration
Questions, feedback and samples for Azure App Configuration service
Stars: ✭ 116 (+480%)
Mutual labels:  config, configuration
Go Config
Robust application configuration made simple
Stars: ✭ 117 (+485%)
Mutual labels:  config, configuration
Project Status: Active - The project has reached a stable, usable state and is being actively developed. CI Status MIT License

GitHub | PyPI | Documentation | Issues | Changelog

javaproperties provides support for reading & writing Java .properties files (both the simple line-oriented format and XML) with a simple API based on the json module — though, for recovering Java addicts, it also includes a Properties class intended to match the behavior of Java 8's java.util.Properties as much as is Pythonically possible.

Previous versions of javaproperties included command-line programs for basic manipulation of .properties files. As of version 0.4.0, these programs have been split off into a separate package, javaproperties-cli.

Installation

javaproperties requires Python 3.7 or higher. Just use pip for Python 3 (You have pip, right?) to install it:

python3 -m pip install javaproperties

Examples

Dump some keys & values (output order not guaranteed):

>>> properties = {"key": "value", "host:port": "127.0.0.1:80", "snowman": "", "goat": "🐐"}
>>> print(javaproperties.dumps(properties))
#Mon Sep 26 14:57:44 EDT 2016
key=value
goat=\ud83d\udc10
host\:port=127.0.0.1\:80
snowman=\u2603

Load some keys & values:

>>> javaproperties.loads('''
... #Mon Sep 26 14:57:44 EDT 2016
... key = value
... goat: \\ud83d\\udc10
... host\\:port=127.0.0.1:80
... #foo = bar
... snowman   ☃
... ''')
{'goat': '🐐', 'host:port': '127.0.0.1:80', 'key': 'value', 'snowman': '☃'}

Dump some properties to a file and read them back in again:

>>> with open('example.properties', 'w', encoding='latin-1') as fp:
...     javaproperties.dump(properties, fp)
...
>>> with open('example.properties', 'r', encoding='latin-1') as fp:
...     javaproperties.load(fp)
...
{'goat': '🐐', 'host:port': '127.0.0.1:80', 'key': 'value', 'snowman': '☃'}

Sort the properties you're dumping:

>>> print(javaproperties.dumps(properties, sort_keys=True))
#Mon Sep 26 14:57:44 EDT 2016
goat=\ud83d\udc10
host\:port=127.0.0.1\:80
key=value
snowman=\u2603

Turn off the timestamp:

>>> print(javaproperties.dumps(properties, timestamp=None))
key=value
goat=\ud83d\udc10
host\:port=127.0.0.1\:80
snowman=\u2603

Use your own timestamp (automatically converted to local time):

>>> print(javaproperties.dumps(properties, timestamp=1234567890))
#Fri Feb 13 18:31:30 EST 2009
key=value
goat=\ud83d\udc10
host\:port=127.0.0.1\:80
snowman=\u2603

Dump as XML:

>>> print(javaproperties.dumps_xml(properties))
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="key">value</entry>
<entry key="goat">🐐</entry>
<entry key="host:port">127.0.0.1:80</entry>
<entry key="snowman">☃</entry>
</properties>

New in v0.6.0: Dump Unicode characters as-is instead of escaping them:

>>> print(javaproperties.dumps(properties, ensure_ascii=False))
#Tue Feb 25 19:13:27 EST 2020
key=value
goat=🐐
host\:port=127.0.0.1\:80
snowman=☃

And more!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].