This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
python_y_malete [24/08/2009 18:26] fernando |
python_y_malete [11/02/2010 00:00] (current) |
||
---|---|---|---|
Line 313: | Line 313: | ||
self.db = args.pop(0) | self.db = args.pop(0) | ||
fdt = self.db.fdt | fdt = self.db.fdt | ||
- | elif fdt and i in fdt.keys() and isinstance(fdt[i], int): | + | elif fdt and i in fdt and isinstance(fdt[i], int): |
- | if not self.append(fdt[i], args.pop(0)) is None: | + | if self.append(fdt[i], args.pop(0)) is not None: |
added += 1 | added += 1 | ||
elif i == ISIS_REC_TEXT: | elif i == ISIS_REC_TEXT: | ||
Line 467: | Line 467: | ||
""" | """ | ||
# need compact array in order to reliably know last index | # need compact array in order to reliably know last index | ||
- | conv = 0 | ||
lines = text.split("\n") | lines = text.split("\n") | ||
if lines and len(lines[0]): | if lines and len(lines[0]): | ||
Line 474: | Line 473: | ||
self.head = line | self.head = line | ||
lines.pop(0) | lines.pop(0) | ||
- | for line in lines: | + | for conv,line in enumerate(lines): |
if '' == line: # blank line or trailing newline | if '' == line: # blank line or trailing newline | ||
continue | continue | ||
dig = strspn(line, '0123456789-') | dig = strspn(line, '0123456789-') | ||
- | t = dig and int(line[0:dig]) or 0 | + | t = dig and int(line[:dig]) or 0 |
- | o = ("\t" == line[dig]) and 1 or 0 | + | o = ("\t" == line[dig]) |
v = line[dig+o:] | v = line[dig+o:] | ||
if repl: | if repl: | ||
Line 485: | Line 484: | ||
self.tag.append(t) | self.tag.append(t) | ||
self.val.append(v) | self.val.append(v) | ||
- | conv += 1 | ||
return conv | return conv | ||
Line 530: | Line 528: | ||
recs If True, fetch a list of records, else of mfns | recs If True, fetch a list of records, else of mfns | ||
""" | """ | ||
- | if expr and recs and not '?' in expr: | + | if expr and recs and '?' not in expr: |
expr += '?' # force fetch records | expr += '?' # force fetch records | ||
ret = self.req('Q', expr) # ret is an IsisRec instance | ret = self.req('Q', expr) # ret is an IsisRec instance | ||
Line 552: | Line 550: | ||
def terms(self, start, to=None): | def terms(self, start, to=None): | ||
- | if not to is None: | + | if to is not None: |
start += '\t' + to | start += '\t' + to | ||
ret = self.req('T', start) | ret = self.req('T', start) |