jbossply


Namejbossply JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/EnigmaBridge/jbossply
SummaryJBoss CLI output parser
upload_time2017-02-20 10:04:06
maintainerNone
docs_urlNone
authorDusan Klinec (ph4r05)
requires_pythonNone
licenseMIT License Copyright (c) 2016 Enigma bridge Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            JBoss CLI output parser
=======================

This simple python library is a JBoss output lexer & parser based on `PLY <http://www.dabeaz.com/ply/>`__
(yet another implementation of lex and yacc for Python).

JBoss CLI server has output that closely resembles JSON, but it is not 100% JSON so it is difficult
to parse it with ordinary tools. With this library you can process JBoss output and parse it as JSON.

Example

.. code:: python

    from jbossply.jbossparser import JbossParser
    test3 = """{
        "outcome" => "success",
        "result" => {
            "rule-1" => {
                "flags" => "L,QSA,R",
                "pattern" => "^/$",
                "substitution" => "/ejbca",
                "condition" => undefined
            },
            "rule-3" => {
                "flags" => "L,QSA,R",
                "pattern" => "^/pki/?$",
                "substitution" => "/ejbca/adminweb",
                "condition" => undefined
            }
        }
    }
    """

    parser = JbossParser()
    print(parser.parse(test3))

Which gives output

::

    {u'outcome': u'success', u'result': {u'rule-3': {u'pattern': u'^/pki/?$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca/adminweb'}, u'rule-1': {u'pattern': u'^/$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca'}}}


You may want to cache parser tables, then create `JbossParser` like this:

.. code:: python

    parser = JbossParser(write_tables=True, outputdir='/tmp/table-dir')


Command line usage
------------------

After installed with pip you may use also the command line helper `jboss2json`.

::

    $ cat jboss-output.txt | jboss2json
    {"outcome": "success", "result": {"rule-3": {"pattern": "^/pki/?$", "flags": "L,QSA,R", "condition": null, "substitution": "/ejbca/adminweb"}, "rule-1": {"pattern": "^/$", "flags": "L,QSA,R", "condition": null, "substitution": "/ejbca"}}}


Installation
------------

You can install this package using pip:

::

    pip install jbossply



Credits
-------

The code is based on @vsajip repository `json-ply <https://github.com/vsajip/json-ply>`__
            

Raw data

            {
    "maintainer": null, 
    "docs_url": null, 
    "requires_python": null, 
    "maintainer_email": null, 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": null, 
    "upload_time": "2017-02-20 10:04:06", 
    "author": "Dusan Klinec (ph4r05)", 
    "home_page": "https://github.com/EnigmaBridge/jbossply", 
    "github_user": "EnigmaBridge", 
    "download_url": "https://pypi.python.org/packages/c9/9b/ba217eb94a56e62128a86293573cec5da8677b156a76b5566e27ea762d65/jbossply-0.0.3.tar.gz", 
    "platform": "UNKNOWN", 
    "version": "0.0.3", 
    "cheesecake_documentation_id": null, 
    "description": "JBoss CLI output parser\n=======================\n\nThis simple python library is a JBoss output lexer & parser based on `PLY <http://www.dabeaz.com/ply/>`__\n(yet another implementation of lex and yacc for Python).\n\nJBoss CLI server has output that closely resembles JSON, but it is not 100% JSON so it is difficult\nto parse it with ordinary tools. With this library you can process JBoss output and parse it as JSON.\n\nExample\n\n.. code:: python\n\n    from jbossply.jbossparser import JbossParser\n    test3 = \"\"\"{\n        \"outcome\" => \"success\",\n        \"result\" => {\n            \"rule-1\" => {\n                \"flags\" => \"L,QSA,R\",\n                \"pattern\" => \"^/$\",\n                \"substitution\" => \"/ejbca\",\n                \"condition\" => undefined\n            },\n            \"rule-3\" => {\n                \"flags\" => \"L,QSA,R\",\n                \"pattern\" => \"^/pki/?$\",\n                \"substitution\" => \"/ejbca/adminweb\",\n                \"condition\" => undefined\n            }\n        }\n    }\n    \"\"\"\n\n    parser = JbossParser()\n    print(parser.parse(test3))\n\nWhich gives output\n\n::\n\n    {u'outcome': u'success', u'result': {u'rule-3': {u'pattern': u'^/pki/?$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca/adminweb'}, u'rule-1': {u'pattern': u'^/$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca'}}}\n\n\nYou may want to cache parser tables, then create `JbossParser` like this:\n\n.. code:: python\n\n    parser = JbossParser(write_tables=True, outputdir='/tmp/table-dir')\n\n\nCommand line usage\n------------------\n\nAfter installed with pip you may use also the command line helper `jboss2json`.\n\n::\n\n    $ cat jboss-output.txt | jboss2json\n    {\"outcome\": \"success\", \"result\": {\"rule-3\": {\"pattern\": \"^/pki/?$\", \"flags\": \"L,QSA,R\", \"condition\": null, \"substitution\": \"/ejbca/adminweb\"}, \"rule-1\": {\"pattern\": \"^/$\", \"flags\": \"L,QSA,R\", \"condition\": null, \"substitution\": \"/ejbca\"}}}\n\n\nInstallation\n------------\n\nYou can install this package using pip:\n\n::\n\n    pip install jbossply\n\n\n\nCredits\n-------\n\nThe code is based on @vsajip repository `json-ply <https://github.com/vsajip/json-ply>`__", 
    "lcname": "jbossply", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": true, 
    "name": "jbossply", 
    "license": "MIT License\n\nCopyright (c) 2016 Enigma bridge\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.", 
    "travis_ci": false, 
    "github_project": "jbossply", 
    "summary": "JBoss CLI output parser", 
    "split_keywords": [], 
    "author_email": "ph4r05@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-02-20T10:04:06", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/c9/9b/ba217eb94a56e62128a86293573cec5da8677b156a76b5566e27ea762d65/jbossply-0.0.3.tar.gz", 
            "md5_digest": "22400ed19c627d5e72b0dde2eaebd096", 
            "downloads": 0, 
            "filename": "jbossply-0.0.3.tar.gz", 
            "packagetype": "sdist", 
            "path": "c9/9b/ba217eb94a56e62128a86293573cec5da8677b156a76b5566e27ea762d65/jbossply-0.0.3.tar.gz", 
            "size": 7185
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}