# coding: utf-8

import os
import time
import codecs
import json

from app import stream

class manager_cl(object):
    exposed = True
    
    def __init__(self):
        self.stream = stream.stream_cl()    
        
    def LIST(self):
        chargenliste = {'1': {}, '2': {}}
        filenames = os.listdir('data')
        for filename in filenames:
            if filename.endswith('.json'):
                charge = codecs.open(os.path.join('data', filename), 'r', 'utf-8')
                chargeData = eval(charge.read())
                charge.close()
                
                charge_id = filename[:-5]
                chargenliste[charge_id]['chargeName'] = chargeData['info']['name']
        print(chargenliste)
        return json.dumps(chargenliste)
                
    
    def LOS(self, charge, los_nr):
        pass
    
    def RECEIVE(self, charge):
        pass