Metadata-Version: 2.4
Name: mango-pycore
Version: 0.1.41
Summary: 
Author: Ernesto Licea Martin
Author-email: ernesto.licea@mango-soft.com
Requires-Python: >=3.11,<4
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Provides-Extra: geo
Requires-Dist: boto3 (>=1.35.0)
Requires-Dist: geoip2 (>=4.8.1) ; extra == "geo"
Requires-Dist: pycryptodome (>=3.23.0)
Requires-Dist: requests (>=2.32.4)
Requires-Dist: rsa (>=4.9.1)
Requires-Dist: websockets (>=13.0)
Description-Content-Type: text/markdown

## Mango Pycore

An implementation of common features for all SAM backend projects for [Mango Soft Inc](http://www.mango-soft.com)

### How to install

```bash
    $ pip install mango-pycore
```

### Geo restriction (optional)

Country allowlist/blocklist checks based on CloudFront's `CloudFront-Viewer-Country` header or a GeoIP
lookup of the client IP. The GeoIP lookup needs the optional `geoip2` dependency and a country `.mmdb`
database, which is **not** bundled: each project ships it and points to it with `GEOIP_DB_PATH`.

```bash
    $ pip install "mango-pycore[geo]"
```

```python
from mango_pycore.geo import GeoRestrictionError

try:
    request.check_geo_restriction({"type": "blocklist", "countries": ["US", "CO"]})
except GeoRestrictionError as e:
    ...  # e.country -> "US" | "UNKNOWN"
```

Options (also accepted by `mango_pycore.geo.check_geo_restriction`): `trust_cloudfront_header` (default
`True`; disable when the API is reachable without CloudFront, the header can be forged),
`trust_forwarded_for` (default `False`) and `fail_closed` (default `False`; deny a blocklist when the
country is unknown).

### Documentation 
To view the documentation in your own machine:
Got to docs/_build/html and view the index.html file (open with live server).

### Create Documentations from Scratch 
Make sure you are working on a virtual environment with Sphinx installed:
(using python 3.9)

```bash
    $ python3 --version
    Python 3.9.7
    $ python3 -m venv venv39
    $ . venv39/bin/activate
```
Install Sphinx and the Sphinx rtd theme:

```bash
    $ pip install -U sphinx
    $ pip install sphinx-rtd-theme
```

Create a docs folder inside the "api" folder:

```bash
    $ mkdir docs
```

Inside the docs folder, start sphinx:

```bash
    $ sphinx-quickstart
```

Fill the documentation information: your name, the project's name and the release number.
Let the language and the separation of the source as default: [eng] an [no].

Go into the "conf.py" document insid the docs folders.
Add the desired path after importing os and sys:

```python
    import os
    import sys
    sys.path.insert(0, os.path.abspath('..'))
```

Modify the extensions:

```python
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.viewcode", "sphinx.ext.todo"]
autodoc_default_options = {
    
    'members': True,
    'undoc-members': False,
    'private-members': True,
    'special-members': False,
    'inherited-members': False,
    'show-inheritance': False,
}
```
Select the desired theme, in this case we will be using the "sphinx rtd theme":

```python
    html_theme = 'sphinx_rtd_theme'
```

In the main folder of the project run:

```bash
    $ sphinx-apidoc -o docs folder_you_want_documented
```
This will create the .rst files for the documentation of the folder you want to document. The .rst files will
appear in the docs folder.

Make sure the modules.rst file references the modules inside your project.
In our case it should look like this:
```python
    mango_pycore
============

.. toctree::
   :maxdepth: 4

   api
   environment_data
   objects
   stream
   tools
   websocket

```
Inside the docs folder run:
```bash
    make html
```

Modify the .rst files to your convenience.













