javaproperties


Namejavaproperties JSON
Version 0.8.1 PyPI version JSON
download
home_pagehttps://github.com/jwodder/javaproperties
SummaryRead & write Java .properties files
upload_time2021-10-05 20:40:04
maintainer
docs_urlNone
authorJohn Thorvald Wodder II
requires_python~=3.6
licenseMIT
keywords java properties javaproperties configfile config configuration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: http://www.repostatus.org/badges/latest/active.svg
    :target: http://www.repostatus.org/#active
    :alt: Project Status: Active - The project has reached a stable, usable
          state and is being actively developed.

.. image:: https://github.com/jwodder/javaproperties/workflows/Test/badge.svg?branch=master
    :target: https://github.com/jwodder/javaproperties/actions?workflow=Test
    :alt: CI Status

.. image:: https://codecov.io/gh/jwodder/javaproperties/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/jwodder/javaproperties

.. image:: https://img.shields.io/pypi/pyversions/javaproperties.svg
    :target: https://pypi.org/project/javaproperties

.. image:: https://img.shields.io/github/license/jwodder/javaproperties.svg?maxAge=2592000
    :target: https://opensource.org/licenses/MIT
    :alt: MIT License

`GitHub <https://github.com/jwodder/javaproperties>`_
| `PyPI <https://pypi.org/project/javaproperties>`_
| `Documentation <https://javaproperties.readthedocs.io>`_
| `Issues <https://github.com/jwodder/javaproperties/issues>`_
| `Changelog <https://github.com/jwodder/javaproperties/blob/master/CHANGELOG.md>`_

``javaproperties`` provides support for reading & writing |properties|_ (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 |propclass|_ 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, |clipkg|_.


Installation
============
``javaproperties`` requires Python 3.6 or higher.  Just use `pip
<https://pip.pypa.io>`_ 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! <https://javaproperties.readthedocs.io>`_


.. |properties| replace:: Java ``.properties`` files
.. _properties: https://en.wikipedia.org/wiki/.properties

.. |propclass| replace:: Java 8's ``java.util.Properties``
.. _propclass: https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html

.. |clipkg| replace:: ``javaproperties-cli``
.. _clipkg: https://github.com/jwodder/javaproperties-cli



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jwodder/javaproperties",
    "name": "javaproperties",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.6",
    "maintainer_email": "",
    "keywords": "java,properties,javaproperties,configfile,config,configuration",
    "author": "John Thorvald Wodder II",
    "author_email": "javaproperties@varonathe.org",
    "download_url": "https://files.pythonhosted.org/packages/68/52/d7db7b671e2d4596c759fb526864837677c1562462e45f0ba46aef9a28c5/javaproperties-0.8.1.tar.gz",
    "platform": "",
    "description": ".. image:: http://www.repostatus.org/badges/latest/active.svg\n    :target: http://www.repostatus.org/#active\n    :alt: Project Status: Active - The project has reached a stable, usable\n          state and is being actively developed.\n\n.. image:: https://github.com/jwodder/javaproperties/workflows/Test/badge.svg?branch=master\n    :target: https://github.com/jwodder/javaproperties/actions?workflow=Test\n    :alt: CI Status\n\n.. image:: https://codecov.io/gh/jwodder/javaproperties/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jwodder/javaproperties\n\n.. image:: https://img.shields.io/pypi/pyversions/javaproperties.svg\n    :target: https://pypi.org/project/javaproperties\n\n.. image:: https://img.shields.io/github/license/jwodder/javaproperties.svg?maxAge=2592000\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n`GitHub <https://github.com/jwodder/javaproperties>`_\n| `PyPI <https://pypi.org/project/javaproperties>`_\n| `Documentation <https://javaproperties.readthedocs.io>`_\n| `Issues <https://github.com/jwodder/javaproperties/issues>`_\n| `Changelog <https://github.com/jwodder/javaproperties/blob/master/CHANGELOG.md>`_\n\n``javaproperties`` provides support for reading & writing |properties|_ (both\nthe simple line-oriented format and XML) with a simple API based on the\n``json`` module \u2014 though, for recovering Java addicts, it also includes a\n``Properties`` class intended to match the behavior of |propclass|_ as much as\nis Pythonically possible.\n\nPrevious versions of ``javaproperties`` included command-line programs for\nbasic manipulation of ``.properties`` files.  As of version 0.4.0, these\nprograms have been split off into a separate package, |clipkg|_.\n\n\nInstallation\n============\n``javaproperties`` requires Python 3.6 or higher.  Just use `pip\n<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install it::\n\n    python3 -m pip install javaproperties\n\n\nExamples\n========\n\nDump some keys & values (output order not guaranteed):\n\n>>> properties = {\"key\": \"value\", \"host:port\": \"127.0.0.1:80\", \"snowman\": \"\u2603\", \"goat\": \"\ud83d\udc10\"}\n>>> print(javaproperties.dumps(properties))\n#Mon Sep 26 14:57:44 EDT 2016\nkey=value\ngoat=\\ud83d\\udc10\nhost\\:port=127.0.0.1\\:80\nsnowman=\\u2603\n\nLoad some keys & values:\n\n>>> javaproperties.loads('''\n... #Mon Sep 26 14:57:44 EDT 2016\n... key = value\n... goat: \\\\ud83d\\\\udc10\n... host\\\\:port=127.0.0.1:80\n... #foo = bar\n... snowman   \u2603\n... ''')\n{'goat': '\ud83d\udc10', 'host:port': '127.0.0.1:80', 'key': 'value', 'snowman': '\u2603'}\n\nDump some properties to a file and read them back in again:\n\n>>> with open('example.properties', 'w', encoding='latin-1') as fp:\n...     javaproperties.dump(properties, fp)\n...\n>>> with open('example.properties', 'r', encoding='latin-1') as fp:\n...     javaproperties.load(fp)\n...\n{'goat': '\ud83d\udc10', 'host:port': '127.0.0.1:80', 'key': 'value', 'snowman': '\u2603'}\n\nSort the properties you're dumping:\n\n>>> print(javaproperties.dumps(properties, sort_keys=True))\n#Mon Sep 26 14:57:44 EDT 2016\ngoat=\\ud83d\\udc10\nhost\\:port=127.0.0.1\\:80\nkey=value\nsnowman=\\u2603\n\nTurn off the timestamp:\n\n>>> print(javaproperties.dumps(properties, timestamp=None))\nkey=value\ngoat=\\ud83d\\udc10\nhost\\:port=127.0.0.1\\:80\nsnowman=\\u2603\n\nUse your own timestamp (automatically converted to local time):\n\n>>> print(javaproperties.dumps(properties, timestamp=1234567890))\n#Fri Feb 13 18:31:30 EST 2009\nkey=value\ngoat=\\ud83d\\udc10\nhost\\:port=127.0.0.1\\:80\nsnowman=\\u2603\n\nDump as XML:\n\n>>> print(javaproperties.dumps_xml(properties))\n<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n<properties>\n<entry key=\"key\">value</entry>\n<entry key=\"goat\">\ud83d\udc10</entry>\n<entry key=\"host:port\">127.0.0.1:80</entry>\n<entry key=\"snowman\">\u2603</entry>\n</properties>\n\nNew in v0.6.0: Dump Unicode characters as-is instead of escaping them:\n\n>>> print(javaproperties.dumps(properties, ensure_ascii=False))\n#Tue Feb 25 19:13:27 EST 2020\nkey=value\ngoat=\ud83d\udc10\nhost\\:port=127.0.0.1\\:80\nsnowman=\u2603\n\n`And more! <https://javaproperties.readthedocs.io>`_\n\n\n.. |properties| replace:: Java ``.properties`` files\n.. _properties: https://en.wikipedia.org/wiki/.properties\n\n.. |propclass| replace:: Java 8's ``java.util.Properties``\n.. _propclass: https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html\n\n.. |clipkg| replace:: ``javaproperties-cli``\n.. _clipkg: https://github.com/jwodder/javaproperties-cli\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Read & write Java .properties files",
    "version": "0.8.1",
    "split_keywords": [
        "java",
        "properties",
        "javaproperties",
        "configfile",
        "config",
        "configuration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9e8613e2e73771df351a92735c64f3b5",
                "sha256": "0e9b43334d6c1a9bffe34e2ece52588e21a7e099869bdaa481a5c6498774e18e"
            },
            "downloads": -1,
            "filename": "javaproperties-0.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e8613e2e73771df351a92735c64f3b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.6",
            "size": 23966,
            "upload_time": "2021-10-05T20:40:03",
            "upload_time_iso_8601": "2021-10-05T20:40:03.613458Z",
            "url": "https://files.pythonhosted.org/packages/47/e8/c244dd03cecdebaf8116c93afaa1c72c8d4833f078a5d35e00c3d2c3be64/javaproperties-0.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "48895f6a9569ba2ed95ac4d793a1bc28",
                "sha256": "9dcba389effe67d3f906bbdcc64b8ef2ee8eac00072406784ea636bb6ba56061"
            },
            "downloads": -1,
            "filename": "javaproperties-0.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "48895f6a9569ba2ed95ac4d793a1bc28",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.6",
            "size": 43881,
            "upload_time": "2021-10-05T20:40:04",
            "upload_time_iso_8601": "2021-10-05T20:40:04.594213Z",
            "url": "https://files.pythonhosted.org/packages/68/52/d7db7b671e2d4596c759fb526864837677c1562462e45f0ba46aef9a28c5/javaproperties-0.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-10-05 20:40:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jwodder",
    "github_project": "javaproperties",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "javaproperties"
}
        
Elapsed time: 0.03335s