Exemplo n.º 1
0
 def __init__(self, key=None, value=None):
     OrderedDict.__init__(self)
     if key != None and value != None:
         self[key] = value
         self._name = value
         self._nametype = key
     else:
         self._name = ''
         self._nametype = ''
Exemplo n.º 2
0
 def __init__(self, key=None, value=None):
     OrderedDict.__init__(self)
     if key != None and value != None:
         self[key] = value
         self._name = value
         self._nametype = key
     else:
         self._name = ''
         self._nametype = ''
Exemplo n.º 3
0
    def readLine(self, line):
        '''
        Reads a single line from the stanza, extracting the key-value pair
        '''

        if line.startswith('#') or line == '':
            OrderedDict.append(self, line)
        else:
            raKey = line.split(' ', 1)[0]
            raVal = ''
            if (len(line.split(' ', 1)) == 2):
                raVal = line.split(' ', 1)[1]
            #if raKey in self:
                #raise KeyError(raKey + ' already exists')
            self[raKey] = raVal
Exemplo n.º 4
0
    def readLine(self, line):
        '''
        Reads a single line from the stanza, extracting the key-value pair
        '''

        if line.startswith('#') or line == '':
            OrderedDict.append(self, line)
        else:
            raKey = line.split(' ', 1)[0].strip()
            raVal = ''
            if (len(line.split(' ', 1)) == 2):
                raVal = line.split(' ', 1)[1].strip()
            #if raKey in self:
                #raise KeyError(raKey + ' already exists')
            self[raKey] = raVal
Exemplo n.º 5
0
    def read(self, filePath, key=None):
        '''
        Reads an rafile stanza by stanza, and internalizes it. Don't override
        this for derived types, instead override readStanza.
        '''
        self._filename = filePath
        file = open(filePath, 'r')
        scopes = list()

        #entry = None
        stanza = list()
        keyValue = ''

        reading = 1

        while reading:
            line = file.readline()  # get the line
            if line == '':
                reading = 0

            # if its a comment or whitespace we append it to the list representation and ignore in dict
            #line = line.strip()
            if len(stanza) == 0 and (line.strip().startswith('#') or
                                     (line.strip() == '' and reading)):
                OrderedDict.append(self, line)
                continue

            if line.strip() != '':
                stanza.append(line)
            elif len(stanza) > 0:
                if keyValue == '':
                    keyValue, name, entry = self.readStanza(stanza, key)
                else:
                    testKey, name, entry = self.readStanza(stanza, key)
                    if entry != None and keyValue != testKey:
                        raise KeyError('Inconsistent Key ' + testKey)

                if entry != None:
                    if name != None or key == None:
                        if name in self:
                            print KeyError('Duplicate Key ' + name)
                        self[name] = entry

                stanza = list()

        file.close()
Exemplo n.º 6
0
    def read(self, filePath, key=None):
        '''
        Reads an rafile stanza by stanza, and internalizes it. Don't override
        this for derived types, instead override readStanza.
        '''
        self._filename = filePath
        file = open(filePath, 'r')
        scopes = list()

        #entry = None
        stanza = list()
        keyValue = ''

        reading = 1
        
        while reading:
            line = file.readline() # get the line
            if line == '':
                reading = 0
        
            # if its a comment or whitespace we append it to the list representation and ignore in dict
            #line = line.strip()
            if len(stanza) == 0 and (line.strip().startswith('#') or (line.strip() == '' and reading)):
                OrderedDict.append(self, line)
                continue

            if line.strip() != '':
                stanza.append(line)
            elif len(stanza) > 0:
                if keyValue == '':
                    keyValue, name, entry = self.readStanza(stanza, key)
                else:
                    testKey, name, entry = self.readStanza(stanza, key)
                    if entry != None and keyValue != testKey:
                        raise KeyError('Inconsistent Key ' + testKey)

                if entry != None:
                    if name != None or key == None:
                        if name in self:
                            print KeyError('Duplicate Key ' + name)
                        self[name] = entry

                stanza = list()

        file.close()
Exemplo n.º 7
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None and os.path.isfile(filePath):
         self.read(filePath, key)
     else:
         self._filename = filePath
Exemplo n.º 8
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None and os.path.isfile(filePath):
         self.read(filePath, key)
     else:
         self._filename = filePath
Exemplo n.º 9
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None:
         self.read(filePath, key)
Exemplo n.º 10
0
Arquivo: soft.py Projeto: bowhan/kent
 def __init__(self, keys, parent):
     self._name = ''
     self._keys = keys
     self.parent = parent
     OrderedDict.__init__(self)
Exemplo n.º 11
0
 def __init__(self, filePath=''):
     OrderedDict.__init__(self)
     if filePath != '':
         self.read(filePath)
Exemplo n.º 12
0
 def append(self, item):
     OrderedDict.append(self, item)
Exemplo n.º 13
0
 def __init__(self):
     self._name = ''
     self._nametype = ''
     OrderedDict.__init__(self)
Exemplo n.º 14
0
 def __init__(self, keys):
     self._name = ''
     self.keys = keys
     OrderedDict.__init__(self)
Exemplo n.º 15
0
	def __init__(self, filePath=''):
		OrderedDict.__init__(self)
		if filePath != '':
			self.read(filePath) 
Exemplo n.º 16
0
 def append(self, item):
     OrderedDict.append(self, item)
Exemplo n.º 17
0
 def __init__(self, keys, parent):
     self._name = ''
     self._keys = keys
     self.parent = parent
     OrderedDict.__init__(self)
Exemplo n.º 18
0
	def __init__(self, keys):
		self._name = ''
		self.keys = keys
		OrderedDict.__init__(self)
Exemplo n.º 19
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None:
         self.read(filePath, key)