#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""The package that contains groups all the functions needed by other scripts."""

import os.path
import sys
sys.path.insert(0, '../')

import logging
import json
import configparser


def get_configuration():
    """Get global configuration from service.cfg"""

    config = configparser.ConfigParser()
    config.read("service.cfg")

    return config

def get_logger(debug):
    """Get logger object"""

    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO
        )
    logger = logging.getLogger(__name__)

    if debug is False:
        logging.disable(logging.CRITICAL)

    return logger

def write_json(data, json_file):
    """General function used everywhere to write data into a json file"""

    with open(json_file, "w") as json_file:
        json.dump(data, json_file)

def read_json(json_file):
    """General function used everywhere to read a json file"""

    with open(json_file, "r") as json_file:
        return json.load(json_file)

def load_subscribers_json():
    """Defining command to check (and create) the subscribers.json file"""

    global SUBSCRIBERS

    if not os.path.isfile("json/subscribers.json"):
        SUBSCRIBERS = []
    else:
        SUBSCRIBERS = read_json("json/subscribers.json")

@@ -1092,19 +1092,52 @@
 rs_json(
+json_file=%22json/subscribers.json%22
 ):%0A
-
     %22%22%22D
@@ -1231,100 +1231,8 @@
 ERS%0A
-%0A    if not os.path.isfile(%22json/subscribers.json%22):%0A        SUBSCRIBERS = %5B%5D%0A    else:%0A    
     
@@ -1259,29 +1259,52 @@
 son(
-%22
 json
-/subscribers.json%22)
+_file) if os.path.isfile(json_file) else %5B%5D
 %0A

Enable testing with other subscriber files