# globconf

Creates a global configparser object, regardless of the project and module in need of it

## Getting Started
In project:
```
from globconf import config
# config will attempt to read local config.ini file if present - otherwise:

if 'important section' not in config.sections():
    config.read_string("""
    [important section]
    host = critical-system.com
    user = REST_USER
    pwd = REST_PASSWORD
    verify_ssl = false
    """)
# or config.read('some_other_config.ini')

# load class using globconf.config
```

In modules:
```
from globconf import config, verify_required_options
class module(object):
    def __init__(self):
        sec = 'service now'
        self.cfg = verify_required_options(sec, ['host', 'user', 'pwd'])
        if not self.cfg.getboolean('verify_ssl', fallback=True):
            import urllib3
            urllib3.disable_warnings(InsecureRequestWarning)
```

And your module is happy as long as someone has initialised the needed section in the global config.

### Prerequisites

configparser

### PyPi server

    mkdir -p ~/projects/pypiserver/data
    cd ~/projects/pypiserver/
    
    htpasswd -sc ~/projects/pypiserver/data/.htaccess some_username
    
create a docker-compose.yml file with the following content:

    ---
    ########################################################################
    # pypiserver docker-compose example
    ########################################################################
    
    version: "3.3"
    
    services:
        pypiserver:
            image: pypiserver/pypiserver:latest
            volumes:
                - type: bind
                  source: ./data
                  target: /data
            # Use an .htaccess file to control access, serve packages from
            # ./data (which will be /data in the container)
            command: -P /data/.htaccess -a update,download,list /data/packages
            ports:
                - "80:8080"
    volumes:
        data:    
    
start up the container:

    (pypiserver) [klang@bascule pypiserver]$ docker-compose up
    Creating network "pypiserver_default" with the default driver
    Creating volume "pypiserver_data" with default driver
    Creating pypiserver_pypiserver_1 ... done
    Attaching to pypiserver_pypiserver_1
    
### Packing

    python setup.py sdist
    twine upload -u some_username -p abc123 --repository-url http://localhost dist/* --skip-existing

    twine upload --repository-url http://test.pypi.org/legacy/ dist/*

### Test that package can be installed

    pyenv virtualenv 3.6.5 testing
    pyenv activate testing
    pip install --index-url http://some_username:abc123@localhost  globconf
    pip uninstall globconf
    pyenv deactivate
    pyenv uninstall -f testing


### Build

    brew install pyenv
    brew install pyenv-virtualenv
    brew install pyenv-virtualenvwrapper
    pyenv install 3.6.5
    pyenv virtualenv 3.6.5 globconf
    pyenv activate globconf
    
    pip install twine
    
    


### Installing

A step by step series of examples that tell you how to get a development env running


```
Give the example
```

And repeat

```
until finished
```

End with an example of getting some data out of the system or using it for a little demo

## Authors

* **Steffen Schumacher** - *Initial work* - [steffenschumacher](https://github.com/steffenschumacher)

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

* Hat tip to anyone whose code was used
* Inspiration
* etc
