__author__ = 'Dilum Bandara'
__version__ = '0.1'
__date__ = '1/3/2011'
__copyright__ = 'Copyright(c) 2011, Dilum Bandara'
__license__ = 'GPL'

import BaseConfig

class Resources:
    """
    Reasources class. Read resource attributes from file
    """
    def __init__(self):
        self.fdIn = open(BaseConfig.RESOURCE_FILE, 'r')
        tmp = self.fdIn.readline() #Read 1st line that contain attribute names
        self._att_set = tmp.split()

    def __del__(self):
        self.fdIn.close()

    def get_attribs(self):
    #  Read attribute set of a node
        tmp = self.fdIn.readline()
        if len(tmp) == 0:
            return []
        tmp_atts = tmp.split()
        atts = []
        for i in range(0, len(tmp_atts)):
            item = [self._att_set[i], tmp_atts[i]]
            atts.append(item)
        return atts 
