def load_from_text(self, data): """ Fill base from string data, contains scripts descriptions """ self.reset() d = {} cur = None script_list = [] for i, line in enumerate(data.splitlines()): line = line.strip() if not line: if d: if not d.has_key('name'): print "Script before line %d have no 'name' parameter" % i else: script = Script() script.load(d) script_list.append(script) d = {} cur = None continue sep = line.find(':') if sep != -1 and line[sep - 1] == '\\': sep = -1 line = line.replace('\\:', ':') if cur is None and sep == -1: print "Unknown attribute at line %d" % i continue if sep != -1: cur = line[:sep].strip().lower() line = line[sep+1:].strip() if line == '.': line = '' d[cur] = line else: if line == '.': line = '' d[cur] = d[cur] + '\n' + line self.from_list(script_list)
def load_from_text(self, data): """ Fill base from string data, contains scripts descriptions """ self.reset() d = {} cur = None script_list = [] for i, line in enumerate(data.splitlines()): line = line.strip() if not line: if d: if not d.has_key('name'): print "Script before line %d have no 'name' parameter" % i else: script = Script() script.load(d) script_list.append(script) d = {} cur = None continue sep = line.find(':') if sep != -1 and line[sep - 1] == '\\': sep = -1 line = line.replace('\\:', ':') if cur is None and sep == -1: print "Unknown attribute at line %d" % i continue if sep != -1: cur = line[:sep].strip().lower() line = line[sep + 1:].strip() if line == '.': line = '' d[cur] = line else: if line == '.': line = '' d[cur] = d[cur] + '\n' + line self.from_list(script_list)