str *joinl(list<str *> *l) { /** Join two or more pathname components, inserting "\" as needed */ list<str *> *__3, *__4, *p; list<str *>::for_in_loop __123; __iter<str *> *__5; str *__2, *b, *path; __ss_int __10, __11, __12, __13, __14, __6, __7, __8, __9, b_wins; __2 = l->__getfast__(0); __3 = l->__slice__(1, 1, 0, 0); path = __2; p = __3; FOR_IN(b,p,4,6,123) b_wins = 0; if (__eq(path, const_1)) { b_wins = 1; } else if (isabs(b)) { if (__OR(__ne(path->__slice__(3, 1, 2, 0), const_19), __eq(b->__slice__(3, 1, 2, 0), const_19), 7)) { b_wins = 1; } else if (__OR((len(path)>3), __AND((len(path)==3), (!(const_18)->__contains__(path->__getitem__(-1))), 10), 9)) { b_wins = 1; } } if (b_wins) { path = b; } else { ASSERT((len(path)>0), 0); if ((const_18)->__contains__(path->__getitem__(-1))) { if ((___bool(b) && (const_18)->__contains__(b->__getitem__(0)))) { path = path->__iadd__(b->__slice__(1, 1, 0, 0)); } else { path = path->__iadd__(b); } } else if (__eq(path->__getitem__(-1), const_19)) { path = path->__iadd__(b); } else if (___bool(b)) { if ((const_18)->__contains__(b->__getitem__(0))) { path = path->__iadd__(b); } else { path = __add_strs(3, path, const_4, b); } } else { path = path->__iadd__(const_4); } } END_FOR return path; }
str *joinl(list<str *> *l) { /** Join two or more pathname components, inserting '/' as needed */ list<str *> *__1, *__2, *p; list<str *>::for_in_loop __123; str *__0, *b, *path; __ss_int __4, __5; __0 = l->__getfast__(0); __1 = l->__slice__(1, 1, 0, 0); path = __0; p = __1; FOR_IN(b,p,2,4,123) if (b->startswith(const_4)) { path = b; } else if (__OR(__eq(path, const_0), path->endswith(const_4), 5)) { path = path->__iadd__(b); } else { path = __add_strs(3, path, const_4, b); } END_FOR return path; }
tuple2<str *, str *> *split(str *p) { /** Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty. */ tuple2<str *, str *> *__15; str *__18, *__19, *__22, *__23, *d, *head, *head2, *tail; __ss_int __16, __17, __20, __21, i; __15 = splitdrive(p); d = __15->__getfirst__(); p = __15->__getsecond__(); i = len(p); while(__AND(i, (!(const_18)->__contains__(p->__getitem__((i-1)))), 16)) { i = (i-1); } __18 = p->__slice__(2, 0, i, 0); __19 = p->__slice__(1, i, 0, 0); head = __18; tail = __19; head2 = head; while((___bool(head2) && (const_18)->__contains__(head2->__getitem__(-1)))) { head2 = head2->__slice__(2, 0, -1, 0); } head = __OR(head2, head, 22); return (new tuple2<str *, str *>(2, d->__add__(head), tail)); }
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)); }
str *normpath(str *path) { /** Normalize path, eliminating double slashes, etc. */ list<str *> *__28, *comps, *new_comps; list<str *>::for_in_loop __123; str *__38, *comp; __ss_int __25, __26, __30, __32, initial_slashes; if (__eq(path, const_0)) { return const_1; } initial_slashes = path->startswith(const_4); if (__AND(initial_slashes, __AND(path->startswith(const_14), (!path->startswith(const_15)), 26), 25)) { initial_slashes = 2; } comps = path->split(const_4); new_comps = (new list<str *>()); FOR_IN(comp,comps,28,30,123) if ((const_2)->__contains__(comp)) { continue; } if ((__ne(comp, const_3) || __AND((!initial_slashes), (!___bool(new_comps)), 32) || ___bool((___bool(new_comps) && __eq(new_comps->__getfast__(-1), const_3))))) { new_comps->append(comp); } else if (___bool(new_comps)) { new_comps->pop(); } END_FOR comps = new_comps; path = (const_4)->join(comps); if (initial_slashes) { path = ((const_4)->__mul__(initial_slashes))->__add__(path); } return __OR(path, const_1, 38); }
__ss_int writer::join_append_data(str *field, __ss_int quote_empty, __ss_int quoted) { str *lineterm; Excel *dialect; __ss_int __17, __18, __19, __20, __21, __22, __23, want_escape; dialect = this->dialect; lineterm = dialect->lineterminator; if ((this->num_fields>0)) { (this->rec)->append(dialect->delimiter); } if (quoted) { (this->rec)->append(dialect->quotechar); } str *c; str::for_in_loop __3; int __2; str *__1; FOR_IN_NEW(c,field,1,2,3) want_escape = 0; if (__eq(c, const_7)) { break; } if (__OR(__eq(c, dialect->delimiter), __OR(__eq(c, dialect->escapechar), __OR(__eq(c, dialect->quotechar), lineterm->__contains__(c), 20), 19), 18)) { if ((dialect->quoting==QUOTE_NONE)) { want_escape = 1; } else { if (__eq(c, dialect->quotechar)) { if (dialect->doublequote) { (this->rec)->append(dialect->quotechar); } else { want_escape = 1; } } if ((!want_escape)) { quoted = 1; } } if (want_escape) { if ((!___bool(dialect->escapechar))) { throw ((new Error(const_18))); } (this->rec)->append(dialect->escapechar); } } (this->rec)->append(c); END_FOR if (__AND((!___bool(field)), quote_empty, 22)) { if ((dialect->quoting==QUOTE_NONE)) { throw ((new Error(const_19))); } else { quoted = 1; } } if (quoted) { (this->rec)->append(dialect->quotechar); } return quoted; }