str * next() { switch(__last_yield) { case 0: goto __after_yield_0; case 1: goto __after_yield_1; case 2: goto __after_yield_2; case 3: goto __after_yield_3; default: break; } if ((!has_magic(pathname))) { if (__os__::__path__::lexists(pathname)) { __last_yield = 0; return pathname; __after_yield_0:; } throw new StopIteration(); } __0 = __os__::__path__::split(pathname); dirname = __0->__getfirst__(); basename = __0->__getsecond__(); if ((!___bool(dirname))) { FOR_IN_SEQ(name,glob1(__os__::curdir, basename),1,3) __last_yield = 1; return name; __after_yield_1:; END_FOR throw new StopIteration(); } if (has_magic(dirname)) { dirs = iglob(dirname); } else { dirs = (new list<str *>(1, dirname)); } if (has_magic(basename)) { FOR_IN(dirname,dirs,5) FOR_IN_SEQ(name,glob1(dirname, basename),7,9) __last_yield = 2; return __os__::__path__::join(2, dirname, name); __after_yield_2:; END_FOR END_FOR } else {
dict<str *, str *> *DictReader::next() { str *key; list<str *> *__31, *row; __iter<str *> *__32; __ss_int __33, lf, lr; dict<str *, str *> *d; if ((this->line_num==0)) { this->getfieldnames(); } row = (this->_reader)->next(); this->line_num = (this->_reader)->line_num; while (row->empty()) { row = (this->_reader)->next(); } d = new dict<str *, str *>(__zip(2, this->getfieldnames(), row)); lf = len(this->getfieldnames()); lr = len(row); if ((lf<lr)) { throw ((new Error(const_20))); } else if ((lf>lr)) { FOR_IN_SEQ(key,(this->getfieldnames())->__slice__(1, lr, 0, 0),31,33) d->__setitem__(key, this->restval); END_FOR }
void *writer::writerow(list<str *> *seq) { list<str *> *__24; __iter<str *> *__25; Excel *dialect; __ss_int __26, quoted; str *field; dialect = this->dialect; this->join_reset(); FOR_IN_SEQ(field,seq,24,26) quoted = 0; if ((dialect->quoting==QUOTE_NONNUMERIC)) { quoted = 1; } else if ((dialect->quoting==QUOTE_ALL)) { quoted = 1; } if ((field==NULL)) { quoted = this->join_append(const_16, quoted, (len(seq)==1)); } else { quoted = this->join_append(__str(field), quoted, (len(seq)==1)); } END_FOR (this->rec)->append((this->dialect)->lineterminator); (this->output_file)->write((const_16)->join(this->rec)); return NULL; }
void *writer::writerows(list<list<str *> *> *seqs) { __iter<list<str *> *> *__28; list<str *> *seq; list<list<str *> *> *__27; __ss_int __29; FOR_IN_SEQ(seq,seqs,27,29) this->writerow(seq); END_FOR return NULL; }
static inline list<str *> *list_comp_1(DictWriter *self, dict<str *, str *> *rowdict) { list<str *> *__37; __iter<str *> *__38; __ss_int __39; str *key; list<str *> *__ss_result = new list<str *>(); __37 = self->fieldnames; __ss_result->resize(len(__37)); FOR_IN_SEQ(key,__37,37,39) __ss_result->units[__39] = rowdict->get(key, self->restval); END_FOR return __ss_result; }