Skip to content

Commit

Permalink
[IMP] config file management
Browse files Browse the repository at this point in the history
  • Loading branch information
ovnicraft committed Jan 5, 2018
1 parent f609e20 commit a2b9214
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
14 changes: 6 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Installing
Using
-----

This library will create a configuration file .runa.json in your HOMEPATH, update this to use it.

.. code-block:: python
>>> import runa
Expand All @@ -52,15 +54,11 @@ Using
Features
--------

* Uso del WS Consultar_Ciudadano
* Validación de NUI (usa librería stdum)
* Uso del WS SRI

* WS Consultar_Ciudadano
* WS SRI
* Config file needed

Credits
---------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
Created by Cristian Salamea
16 changes: 15 additions & 1 deletion runa/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# -*- coding: utf-8 -*-

import json
from pathlib import Path
import logging

logger = logging.getLogger(__name__)

CONFIG_FILE_NAME = '.runa.json'

CONFIG_FILE = '{0}/{1}'.format(str(Path.home()), CONFIG_FILE_NAME)

if not Path(CONFIG_FILE).is_file():
mf = open(CONFIG_FILE, 'w')
json.dumps({}, mf)
mf.close()

CONFIG_FILE = '/var/tmp/config.json'

# Read config
with open(CONFIG_FILE) as env_file:
VARS_ENV = json.load(env_file)
if not VARS_ENV:
logger.warning('No vars defined, please update your %s' % CONFIG_FILE)

AUTHORIZED_NUI = VARS_ENV.get('AUTHORIZED_NUI', None)
WS_CIUDADANO_PRODUCTION = VARS_ENV.get('WS_CIUDADANO_PRODUCTION', None)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='runa',
version='0.2.2',
version='0.2.3',
description="Librería para uso de WS del Bus Gubernamental de Ecuador",
long_description=readme + '\n\n' + history,
author="Cristian Salamea",
Expand Down

0 comments on commit a2b9214

Please sign in to comment.