tuple2<__ss_bool, str *> *long_has_args(str *opt, pyiter<str *> *longopts) { list<str *> *possibilities; str *unique_match; __ss_bool has_arg; possibilities = list_comp_0(opt, longopts); if ((!___bool(possibilities))) { throw ((new GetoptError(__modct(const_8, 1, opt),opt))); } if (possibilities->__contains__(opt)) { return (new tuple2<__ss_bool, str *>(2, False, opt)); } else if (possibilities->__contains__(opt->__add__(const_5))) { return (new tuple2<__ss_bool, str *>(2, True, opt)); } if ((len(possibilities)>1)) { throw ((new GetoptError(__modct(const_9, 1, opt),opt))); } ASSERT((len(possibilities)==1), 0); unique_match = possibilities->__getfast__(0); has_arg = __mbool(unique_match->endswith(const_5)); if (has_arg) { unique_match = unique_match->__slice__(2, 0, -1, 0); } return (new tuple2<__ss_bool, str *>(2, has_arg, unique_match)); }
str *__xrange::__repr__() { if(s==1) { if(a==0) return __modct(new str("xrange(%d)"), 1, ___box(b)); else return __modct(new str("xrange(%d, %d)"), 2, ___box(a), ___box(b)); } return __modct(new str("xrange(%d, %d, %d)"), 3, ___box(a), ___box(b), ___box(s)); /* XXX */ }
str *complex::__repr__() { str *left, *middle, *right; if(real==0) return __modct(new str("%gj"), 1, ___box(imag)); left = __modct(new str("(%g"), 1, ___box(real)); if(imag<0) middle = new str(""); else middle = new str("+"); right = __modct(new str("%gj)"), 1, ___box(imag)); return __add_strs(3, left, middle, right); }
tuple2<list<tuple2<str *, str *> *> *, list<str *> *> *do_shorts(list<tuple2<str *, str *> *> *opts, str *optstring, str *shortopts, list<str *> *args) { list<str *> *__22; str *__19, *__20, *__21, *__23, *opt, *optarg; while(__ne(optstring, const_0)) { __19 = optstring->__getitem__(0); __20 = optstring->__slice__(1, 1, 0, 0); opt = __19; optstring = __20; if (short_has_arg(opt, shortopts)) { if (__eq(optstring, const_0)) { if ((!___bool(args))) { throw ((new GetoptError(__modct(const_10, 1, opt),opt))); } __21 = args->__getfast__(0); __22 = args->__slice__(1, 1, 0, 0); optstring = __21; args = __22; } __23 = optstring; optarg = __23; optstring = const_0; } else { optarg = const_0; } opts->append((new tuple2<str *, str *>(2, (const_1)->__add__(opt), optarg))); } return (new tuple2<list<tuple2<str *, str *> *> *, list<str *> *>(2, opts, args)); }
void *reader::parse_add_char(str *c) { if ((len(this->field)>=_field_limit)) { throw ((new Error(__modct(const_17, 1, ___box(_field_limit))))); } (this->field)->append(c); return NULL; }
tuple2<list<tuple2<str *, str *> *> *, list<str *> *> *do_longs(list<tuple2<str *, str *> *> *opts, str *opt, pyiter<str *> *longopts, list<str *> *args) { list<str *> *__13; str *__12, *__14, *__15, *__8, *__9, *optarg; __ss_int __10, i; __ss_bool has_arg; tuple2<__ss_bool, str *> *__11; try { __10 = 0; i = opt->index(const_5); __10 = 1; } catch (ValueError *) { optarg = 0; } if(__10) { // else __8 = opt->__slice__(2, 0, i, 0); __9 = opt->__slice__(1, (i+1), 0, 0); opt = __8; optarg = __9; } __11 = long_has_args(opt, longopts); has_arg = __11->__getfirst__(); opt = __11->__getsecond__(); if (has_arg) { if ((optarg==0)) { if ((!___bool(args))) { throw ((new GetoptError(__modct(const_6, 1, opt),opt))); } __12 = args->__getfast__(0); __13 = args->__slice__(1, 1, 0, 0); optarg = __12; args = __13; } } else if (___bool(optarg)) { throw ((new GetoptError(__modct(const_7, 1, opt),opt))); } opts->append((new tuple2<str *, str *>(2, (const_2)->__add__(opt), __OR(optarg, const_0, 14)))); return (new tuple2<list<tuple2<str *, str *> *> *, list<str *> *>(2, opts, args)); }
__ss_bool short_has_arg(str *opt, str *shortopts) { str *__26; __ss_int __24, __25, i; FAST_FOR(i,0,len(shortopts),1,24,25) if ((__eq(opt, (__26=shortopts->__getitem__(i)))&&__ne(__26, const_11))) { return __mbool(shortopts->startswith(const_11, (i+1))); } END_FOR throw ((new GetoptError(__modct(const_12, 1, opt),opt))); }
void *reader::parse_process_char(str *c) { Excel *dialect; __ss_int __10, __11, __12, __13, __14, __7, __8, __9; dialect = this->dialect; if ((this->state==START_RECORD)) { if (__eq(c, const_7)) { return NULL; } else if ((const_8)->__contains__(c)) { this->state = EAT_CRNL; return NULL; } this->state = START_FIELD; } if ((this->state==START_FIELD)) { if ((const_9)->__contains__(c)) { this->parse_save_field(); if (__eq(c, const_7)) { this->state = START_RECORD; } else { this->state = EAT_CRNL; } } else if (__AND(__eq(c, dialect->quotechar), (dialect->quoting!=QUOTE_NONE), 7)) { this->state = IN_QUOTED_FIELD; } else if (__eq(c, dialect->escapechar)) { this->state = ESCAPED_CHAR; } else if (__AND(__eq(c, const_10), dialect->skipinitialspace, 9)) { } else if (__eq(c, dialect->delimiter)) { this->parse_save_field(); } else { if ((dialect->quoting==QUOTE_NONNUMERIC)) { this->numeric_field = 1; } this->parse_add_char(c); this->state = IN_FIELD; } } else if ((this->state==ESCAPED_CHAR)) { if (__eq(c, const_7)) { c = const_11; } this->parse_add_char(c); this->state = IN_FIELD; } else if ((this->state==IN_FIELD)) { if ((const_12)->__contains__(c)) { this->parse_save_field(); if (__eq(c, const_7)) { this->state = START_RECORD; } else { this->state = EAT_CRNL; } } else if (__eq(c, dialect->escapechar)) { this->state = ESCAPED_CHAR; } else if (__eq(c, dialect->delimiter)) { this->parse_save_field(); this->state = START_FIELD; } else { this->parse_add_char(c); } } else if ((this->state==IN_QUOTED_FIELD)) { if (__eq(c, const_7)) { } else if (__eq(c, dialect->escapechar)) { this->state = ESCAPE_IN_QUOTED_FIELD; } else if (__AND(__eq(c, dialect->quotechar), (dialect->quoting!=QUOTE_NONE), 11)) { if (dialect->doublequote) { this->state = QUOTE_IN_QUOTED_FIELD; } else { this->state = IN_FIELD; } } else { this->parse_add_char(c); } } else if ((this->state==ESCAPE_IN_QUOTED_FIELD)) { if (__eq(c, const_7)) { c = const_11; } this->parse_add_char(c); this->state = IN_QUOTED_FIELD; } else if ((this->state==QUOTE_IN_QUOTED_FIELD)) { if (__AND((dialect->quoting!=QUOTE_NONE), __eq(c, dialect->quotechar), 13)) { this->parse_add_char(c); this->state = IN_QUOTED_FIELD; } else if (__eq(c, dialect->delimiter)) { this->parse_save_field(); this->state = START_FIELD; } else if ((const_12)->__contains__(c)) { this->parse_save_field(); if (__eq(c, const_7)) { this->state = START_RECORD; } else { this->state = EAT_CRNL; } } else if ((!dialect->strict)) { this->parse_add_char(c); this->state = IN_FIELD; } else { throw ((new Error(__modct(const_13, 2, dialect->delimiter, dialect->quotechar)))); } } else if ((this->state==EAT_CRNL)) { if ((const_8)->__contains__(c)) { } else if (__eq(c, const_7)) { this->state = START_RECORD; } else { throw ((new Error(const_14))); } } return 0; }