cedashtools


Namecedashtools JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryFor use in your Centric Engineers tools
upload_time2024-10-18 17:24:39
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseThe MIT License (MIT) Copyright © 2024 Centric Engineers 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 centric engineers
VCS
bugtrack_url
requirements build certifi cffi charset-normalizer cryptography docutils idna importlib-metadata importlib-resources jaraco.classes keyring markdown-it-py mdurl more-itertools nh3 packaging pip-autoremove pkginfo pycparser Pygments pyproject_hooks readme-renderer requests requests-toolbelt rfc3986 rich tenacity tomli twine typing_extensions urllib3 zipp
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Summary
Use this package with your Centric Engineers tools to acquire user access levels from CentricEngineers.com.

# Usage

## Single Page Dash App
In a simple single page Dash-Plotly application.

```python
import dash
from dash import dcc, html, Input, Output
from cedashtools.user_access import validation, encryption
from cedashtools.user_access.website import AccessLevel, ToolPayload, ce_validation_url


app = dash.Dash(__name__)

app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Div(id='content'),
])


@app.callback(Output('content', 'children'),
              Input('url', 'search'))
def display_content_based_on_access(search: str):
    # Tool ID provided by centricengineers.com
    tool_id = 'a_tool_id'
    
    # encryption keys can be specified by file path
    encryption.keys.PUBLIC_KEY_FILE_PATH = r'/Path/To/File/Containing/Public_Key'
    encryption.keys.PRIVATE_KEY_FILE_PATH = r'/Path/To/File/Containing/Private_Key'
    
    # get user's access level
    user_id = validation.get_user_id(validation.parse_url_params(search))  # URL vars contain user information
    payload = ToolPayload(user_id, tool_id)
    access_level = validation.get_access_level(ce_validation_url, payload, encryption.keys)
    
    # display content based on access level
    if access_level >= AccessLevel.PRO:
        layout = html.Div([html.H1(["Paid Content"])])
    else:
        layout = html.Div([html.H1(["Free Content"])])
    return layout
```

## Mult-Page Dash App
In a multi-page Dash-Plotly application (using pages).

### app.py
```python
import dash
from dash import html, dcc

APP_TITLE = "Dash App"  

app = dash.Dash(
    __name__,
    title=APP_TITLE,
    use_pages=True,  # New in Dash 2.7 - Allows us to register pages
)

app.layout = html.Div([dash.page_container])

server = app.server

if __name__ == '__main__':
    app.run_server(debug=True)
```

### home.py

```python
from dash import html, register_page
from cedashtools.user_access import validation, encryption
from cedashtools.user_access.website import AccessLevel, ToolPayload, ce_validation_url

register_page(
    __name__,
    name='Home',
    path='/'
)


def layout(**url_vars):  # URL vars contain user information
    
    # Tool ID provided by CentricEngineers.com
    tool_id = 'a_tool_id'

    # encryption keys can also be specified by string
    encryption.keys.PUBLIC_KEY_STRING = '-----BEGIN PUBLIC KEY-----FakePublicKey-----END PUBLIC KEY-----'
    encryption.keys.PRIVATE_KEY_STRING = '-----BEGIN PRIVATE KEY-----FakePrivateKey-----END PRIVATE KEY-----'

    # get user's access level
    user_id = validation.get_user_id(url_vars)
    payload = ToolPayload(user_id, tool_id)
    access_level = validation.get_access_level(ce_validation_url, payload, encryption.keys)

    # display content based on access level
    if access_level >= AccessLevel.PRO:
        layout = html.Div([html.H1(["Paid Content"])])
    else:
        layout = html.Div([html.H1(["Free Content"])])
    return layout
```

# Change Log

## Version 0.3.0 (10-18-2024)

- Added cryptography support
- Refactored API


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cedashtools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Centric Engineers",
    "author": null,
    "author_email": "Centric Engineers <admin@centricengineers.com>",
    "download_url": "https://files.pythonhosted.org/packages/29/2f/22643c8cf1707a4f9e29a1847fac5ae4ff8e4019aa533774a12c9be91f1b/cedashtools-0.3.0.tar.gz",
    "platform": null,
    "description": "# Summary\nUse this package with your Centric Engineers tools to acquire user access levels from CentricEngineers.com.\n\n# Usage\n\n## Single Page Dash App\nIn a simple single page Dash-Plotly application.\n\n```python\nimport dash\nfrom dash import dcc, html, Input, Output\nfrom cedashtools.user_access import validation, encryption\nfrom cedashtools.user_access.website import AccessLevel, ToolPayload, ce_validation_url\n\n\napp = dash.Dash(__name__)\n\napp.layout = html.Div([\n    dcc.Location(id='url', refresh=False),\n    html.Div(id='content'),\n])\n\n\n@app.callback(Output('content', 'children'),\n              Input('url', 'search'))\ndef display_content_based_on_access(search: str):\n    # Tool ID provided by centricengineers.com\n    tool_id = 'a_tool_id'\n    \n    # encryption keys can be specified by file path\n    encryption.keys.PUBLIC_KEY_FILE_PATH = r'/Path/To/File/Containing/Public_Key'\n    encryption.keys.PRIVATE_KEY_FILE_PATH = r'/Path/To/File/Containing/Private_Key'\n    \n    # get user's access level\n    user_id = validation.get_user_id(validation.parse_url_params(search))  # URL vars contain user information\n    payload = ToolPayload(user_id, tool_id)\n    access_level = validation.get_access_level(ce_validation_url, payload, encryption.keys)\n    \n    # display content based on access level\n    if access_level >= AccessLevel.PRO:\n        layout = html.Div([html.H1([\"Paid Content\"])])\n    else:\n        layout = html.Div([html.H1([\"Free Content\"])])\n    return layout\n```\n\n## Mult-Page Dash App\nIn a multi-page Dash-Plotly application (using pages).\n\n### app.py\n```python\nimport dash\nfrom dash import html, dcc\n\nAPP_TITLE = \"Dash App\"  \n\napp = dash.Dash(\n    __name__,\n    title=APP_TITLE,\n    use_pages=True,  # New in Dash 2.7 - Allows us to register pages\n)\n\napp.layout = html.Div([dash.page_container])\n\nserver = app.server\n\nif __name__ == '__main__':\n    app.run_server(debug=True)\n```\n\n### home.py\n\n```python\nfrom dash import html, register_page\nfrom cedashtools.user_access import validation, encryption\nfrom cedashtools.user_access.website import AccessLevel, ToolPayload, ce_validation_url\n\nregister_page(\n    __name__,\n    name='Home',\n    path='/'\n)\n\n\ndef layout(**url_vars):  # URL vars contain user information\n    \n    # Tool ID provided by CentricEngineers.com\n    tool_id = 'a_tool_id'\n\n    # encryption keys can also be specified by string\n    encryption.keys.PUBLIC_KEY_STRING = '-----BEGIN PUBLIC KEY-----FakePublicKey-----END PUBLIC KEY-----'\n    encryption.keys.PRIVATE_KEY_STRING = '-----BEGIN PRIVATE KEY-----FakePrivateKey-----END PRIVATE KEY-----'\n\n    # get user's access level\n    user_id = validation.get_user_id(url_vars)\n    payload = ToolPayload(user_id, tool_id)\n    access_level = validation.get_access_level(ce_validation_url, payload, encryption.keys)\n\n    # display content based on access level\n    if access_level >= AccessLevel.PRO:\n        layout = html.Div([html.H1([\"Paid Content\"])])\n    else:\n        layout = html.Div([html.H1([\"Free Content\"])])\n    return layout\n```\n\n# Change Log\n\n## Version 0.3.0 (10-18-2024)\n\n- Added cryptography support\n- Refactored API\n\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT) Copyright \u00a9 2024 Centric Engineers  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), 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 \u201cAS IS\u201d, 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.",
    "summary": "For use in your Centric Engineers tools",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/CentricEngineers/cedashtools.git"
    },
    "split_keywords": [
        "centric",
        "engineers"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53c7d3f2a4c4ebc70d2101a02adf0070a809795a2b2eed1b04ec76032bc71b69",
                "md5": "66d96fa6a5984b9e16bd0ff3e81f2ff2",
                "sha256": "ae3784ac27620318cdb40d623487f3dd919a56a3ce63c74d444c7ea131e26046"
            },
            "downloads": -1,
            "filename": "cedashtools-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "66d96fa6a5984b9e16bd0ff3e81f2ff2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7005,
            "upload_time": "2024-10-18T17:24:38",
            "upload_time_iso_8601": "2024-10-18T17:24:38.385105Z",
            "url": "https://files.pythonhosted.org/packages/53/c7/d3f2a4c4ebc70d2101a02adf0070a809795a2b2eed1b04ec76032bc71b69/cedashtools-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "292f22643c8cf1707a4f9e29a1847fac5ae4ff8e4019aa533774a12c9be91f1b",
                "md5": "4eb03ca5ab6e0c7559dff019fe8f7fa1",
                "sha256": "12a68ea4e1c3c8eee1bde5a2fa1f09543b044906e579f5ac7171b7d3baf90344"
            },
            "downloads": -1,
            "filename": "cedashtools-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4eb03ca5ab6e0c7559dff019fe8f7fa1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5271,
            "upload_time": "2024-10-18T17:24:39",
            "upload_time_iso_8601": "2024-10-18T17:24:39.447054Z",
            "url": "https://files.pythonhosted.org/packages/29/2f/22643c8cf1707a4f9e29a1847fac5ae4ff8e4019aa533774a12c9be91f1b/cedashtools-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-18 17:24:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CentricEngineers",
    "github_project": "cedashtools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "build",
            "specs": [
                [
                    "==",
                    "1.0.3"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.7.4"
                ]
            ]
        },
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.17.1"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.3.2"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "43.0.1"
                ]
            ]
        },
        {
            "name": "docutils",
            "specs": [
                [
                    "==",
                    "0.20.1"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.8"
                ]
            ]
        },
        {
            "name": "importlib-metadata",
            "specs": [
                [
                    "==",
                    "7.0.1"
                ]
            ]
        },
        {
            "name": "importlib-resources",
            "specs": [
                [
                    "==",
                    "6.1.1"
                ]
            ]
        },
        {
            "name": "jaraco.classes",
            "specs": [
                [
                    "==",
                    "3.3.0"
                ]
            ]
        },
        {
            "name": "keyring",
            "specs": [
                [
                    "==",
                    "24.3.0"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "more-itertools",
            "specs": [
                [
                    "==",
                    "10.2.0"
                ]
            ]
        },
        {
            "name": "nh3",
            "specs": [
                [
                    "==",
                    "0.2.15"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "23.2"
                ]
            ]
        },
        {
            "name": "pip-autoremove",
            "specs": [
                [
                    "==",
                    "0.10.0"
                ]
            ]
        },
        {
            "name": "pkginfo",
            "specs": [
                [
                    "==",
                    "1.9.6"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.22"
                ]
            ]
        },
        {
            "name": "Pygments",
            "specs": [
                [
                    "==",
                    "2.17.2"
                ]
            ]
        },
        {
            "name": "pyproject_hooks",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "readme-renderer",
            "specs": [
                [
                    "==",
                    "42.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "requests-toolbelt",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "rfc3986",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "13.7.0"
                ]
            ]
        },
        {
            "name": "tenacity",
            "specs": [
                [
                    "==",
                    "9.0.0"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "5.1.1"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    "==",
                    "4.9.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.2.2"
                ]
            ]
        },
        {
            "name": "zipp",
            "specs": [
                [
                    "==",
                    "3.17.0"
                ]
            ]
        }
    ],
    "lcname": "cedashtools"
}
        
Elapsed time: 0.33923s