�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PK1] Dbm.pycnu[ ^c@s'dddYZdZedS(tDbmcBsPeZdZdZdZdZdZdZdZdZ RS(cCs(ddl}|j||||_dS(Ni(tdbmtopentdb(tselftfilenametmodetpermR((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__init__ s cCsdd}xO|jD]A}t|dt||}|rJd|}n||}qWd|dS(Nts: s, t{t}(tkeystrepr(Rtstkeytt((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__repr__ s cCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__len__scCst|jt|S(N(tevalRR (RR((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt __getitem__scCst||jt|s$ PK1]nL6 6 Range.pynu["""Example of a generator: re-implement the built-in range function without actually constructing the list of values. OldStyleRange is coded in the way required to work in a 'for' loop before iterators were introduced into the language; using __getitem__ and __len__ . """ def handleargs(arglist): """Take list of arguments and extract/create proper start, stop, and step values and return in a tuple""" try: if len(arglist) == 1: return 0, int(arglist[0]), 1 elif len(arglist) == 2: return int(arglist[0]), int(arglist[1]), 1 elif len(arglist) == 3: if arglist[2] == 0: raise ValueError("step argument must not be zero") return tuple(int(x) for x in arglist) else: raise TypeError("range() accepts 1-3 arguments, given", len(arglist)) except TypeError: raise TypeError("range() arguments must be numbers or strings " "representing numbers") def genrange(*a): """Function to implement 'range' as a generator""" start, stop, step = handleargs(a) value = start while value < stop: yield value value += step class oldrange: """Class implementing a range object. To the user the instances feel like immutable sequences (and you can't concatenate or slice them) Done using the old way (pre-iterators; __len__ and __getitem__) to have an object be used by a 'for' loop. """ def __init__(self, *a): """ Initialize start, stop, and step values along with calculating the nubmer of values (what __len__ will return) in the range""" self.start, self.stop, self.step = handleargs(a) self.len = max(0, (self.stop - self.start) // self.step) def __repr__(self): """implement repr(x) which is also used by print""" return 'range(%r, %r, %r)' % (self.start, self.stop, self.step) def __len__(self): """implement len(x)""" return self.len def __getitem__(self, i): """implement x[i]""" if 0 <= i <= self.len: return self.start + self.step * i else: raise IndexError, 'range[i] index out of range' def test(): import time, __builtin__ #Just a quick sanity check correct_result = __builtin__.range(5, 100, 3) oldrange_result = list(oldrange(5, 100, 3)) genrange_result = list(genrange(5, 100, 3)) if genrange_result != correct_result or oldrange_result != correct_result: raise Exception("error in implementation:\ncorrect = %s" "\nold-style = %s\ngenerator = %s" % (correct_result, oldrange_result, genrange_result)) print "Timings for range(1000):" t1 = time.time() for i in oldrange(1000): pass t2 = time.time() for i in genrange(1000): pass t3 = time.time() for i in __builtin__.range(1000): pass t4 = time.time() print t2-t1, 'sec (old-style class)' print t3-t2, 'sec (generator)' print t4-t3, 'sec (built-in)' if __name__ == '__main__': test() PK1](( bitvec.pynu[# # this is a rather strict implementation of a bit vector class # it is accessed the same way as an array of python-ints, except # the value must be 0 or 1 # import sys; rprt = sys.stderr.write #for debugging class error(Exception): pass def _check_value(value): if type(value) != type(0) or not 0 <= value < 2: raise error, 'bitvec() items must have int value 0 or 1' import math def _compute_len(param): mant, l = math.frexp(float(param)) bitmask = 1L << l if bitmask <= param: raise RuntimeError('(param, l) = %r' % ((param, l),)) while l: bitmask = bitmask >> 1 if param & bitmask: break l = l - 1 return l def _check_key(len, key): if type(key) != type(0): raise TypeError, 'sequence subscript not int' if key < 0: key = key + len if not 0 <= key < len: raise IndexError, 'list index out of range' return key def _check_slice(len, i, j): #the type is ok, Python already checked that i, j = max(i, 0), min(len, j) if i > j: i = j return i, j class BitVec: def __init__(self, *params): self._data = 0L self._len = 0 if not len(params): pass elif len(params) == 1: param, = params if type(param) == type([]): value = 0L bit_mask = 1L for item in param: # strict check #_check_value(item) if item: value = value | bit_mask bit_mask = bit_mask << 1 self._data = value self._len = len(param) elif type(param) == type(0L): if param < 0: raise error, 'bitvec() can\'t handle negative longs' self._data = param self._len = _compute_len(param) else: raise error, 'bitvec() requires array or long parameter' elif len(params) == 2: param, length = params if type(param) == type(0L): if param < 0: raise error, \ 'can\'t handle negative longs' self._data = param if type(length) != type(0): raise error, 'bitvec()\'s 2nd parameter must be int' computed_length = _compute_len(param) if computed_length > length: print 'warning: bitvec() value is longer than the length indicates, truncating value' self._data = self._data & \ ((1L << length) - 1) self._len = length else: raise error, 'bitvec() requires array or long parameter' else: raise error, 'bitvec() requires 0 -- 2 parameter(s)' def append(self, item): #_check_value(item) #self[self._len:self._len] = [item] self[self._len:self._len] = \ BitVec(long(not not item), 1) def count(self, value): #_check_value(value) if value: data = self._data else: data = (~self)._data count = 0 while data: data, count = data >> 1, count + (data & 1 != 0) return count def index(self, value): #_check_value(value): if value: data = self._data else: data = (~self)._data index = 0 if not data: raise ValueError, 'list.index(x): x not in list' while not (data & 1): data, index = data >> 1, index + 1 return index def insert(self, index, item): #_check_value(item) #self[index:index] = [item] self[index:index] = BitVec(long(not not item), 1) def remove(self, value): del self[self.index(value)] def reverse(self): #ouch, this one is expensive! #for i in self._len>>1: self[i], self[l-i] = self[l-i], self[i] data, result = self._data, 0L for i in range(self._len): if not data: result = result << (self._len - i) break result, data = (result << 1) | (data & 1), data >> 1 self._data = result def sort(self): c = self.count(1) self._data = ((1L << c) - 1) << (self._len - c) def copy(self): return BitVec(self._data, self._len) def seq(self): result = [] for i in self: result.append(i) return result def __repr__(self): ##rprt('.' + '__repr__()\n') return 'bitvec(%r, %r)' % (self._data, self._len) def __cmp__(self, other, *rest): #rprt('%r.__cmp__%r\n' % (self, (other,) + rest)) if type(other) != type(self): other = apply(bitvec, (other, ) + rest) #expensive solution... recursive binary, with slicing length = self._len if length == 0 or other._len == 0: return cmp(length, other._len) if length != other._len: min_length = min(length, other._len) return cmp(self[:min_length], other[:min_length]) or \ cmp(self[min_length:], other[min_length:]) #the lengths are the same now... if self._data == other._data: return 0 if length == 1: return cmp(self[0], other[0]) else: length = length >> 1 return cmp(self[:length], other[:length]) or \ cmp(self[length:], other[length:]) def __len__(self): #rprt('%r.__len__()\n' % (self,)) return self._len def __getitem__(self, key): #rprt('%r.__getitem__(%r)\n' % (self, key)) key = _check_key(self._len, key) return self._data & (1L << key) != 0 def __setitem__(self, key, value): #rprt('%r.__setitem__(%r, %r)\n' % (self, key, value)) key = _check_key(self._len, key) #_check_value(value) if value: self._data = self._data | (1L << key) else: self._data = self._data & ~(1L << key) def __delitem__(self, key): #rprt('%r.__delitem__(%r)\n' % (self, key)) key = _check_key(self._len, key) #el cheapo solution... self._data = self[:key]._data | self[key+1:]._data >> key self._len = self._len - 1 def __getslice__(self, i, j): #rprt('%r.__getslice__(%r, %r)\n' % (self, i, j)) i, j = _check_slice(self._len, i, j) if i >= j: return BitVec(0L, 0) if i: ndata = self._data >> i else: ndata = self._data nlength = j - i if j != self._len: #we'll have to invent faster variants here #e.g. mod_2exp ndata = ndata & ((1L << nlength) - 1) return BitVec(ndata, nlength) def __setslice__(self, i, j, sequence, *rest): #rprt('%s.__setslice__%r\n' % (self, (i, j, sequence) + rest)) i, j = _check_slice(self._len, i, j) if type(sequence) != type(self): sequence = apply(bitvec, (sequence, ) + rest) #sequence is now of our own type ls_part = self[:i] ms_part = self[j:] self._data = ls_part._data | \ ((sequence._data | \ (ms_part._data << sequence._len)) << ls_part._len) self._len = self._len - j + i + sequence._len def __delslice__(self, i, j): #rprt('%r.__delslice__(%r, %r)\n' % (self, i, j)) i, j = _check_slice(self._len, i, j) if i == 0 and j == self._len: self._data, self._len = 0L, 0 elif i < j: self._data = self[:i]._data | (self[j:]._data >> i) self._len = self._len - j + i def __add__(self, other): #rprt('%r.__add__(%r)\n' % (self, other)) retval = self.copy() retval[self._len:self._len] = other return retval def __mul__(self, multiplier): #rprt('%r.__mul__(%r)\n' % (self, multiplier)) if type(multiplier) != type(0): raise TypeError, 'sequence subscript not int' if multiplier <= 0: return BitVec(0L, 0) elif multiplier == 1: return self.copy() #handle special cases all 0 or all 1... if self._data == 0L: return BitVec(0L, self._len * multiplier) elif (~self)._data == 0L: return ~BitVec(0L, self._len * multiplier) #otherwise el cheapo again... retval = BitVec(0L, 0) while multiplier: retval, multiplier = retval + self, multiplier - 1 return retval def __and__(self, otherseq, *rest): #rprt('%r.__and__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): otherseq = apply(bitvec, (otherseq, ) + rest) #sequence is now of our own type return BitVec(self._data & otherseq._data, \ min(self._len, otherseq._len)) def __xor__(self, otherseq, *rest): #rprt('%r.__xor__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): otherseq = apply(bitvec, (otherseq, ) + rest) #sequence is now of our own type return BitVec(self._data ^ otherseq._data, \ max(self._len, otherseq._len)) def __or__(self, otherseq, *rest): #rprt('%r.__or__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): otherseq = apply(bitvec, (otherseq, ) + rest) #sequence is now of our own type return BitVec(self._data | otherseq._data, \ max(self._len, otherseq._len)) def __invert__(self): #rprt('%r.__invert__()\n' % (self,)) return BitVec(~self._data & ((1L << self._len) - 1), \ self._len) def __coerce__(self, otherseq, *rest): #needed for *some* of the arithmetic operations #rprt('%r.__coerce__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): otherseq = apply(bitvec, (otherseq, ) + rest) return self, otherseq def __int__(self): return int(self._data) def __long__(self): return long(self._data) def __float__(self): return float(self._data) bitvec = BitVec PK1]IRev.pynu[''' A class which presents the reverse of a sequence without duplicating it. From: "Steven D. Majewski" It works on mutable or inmutable sequences. >>> chars = list(Rev('Hello World!')) >>> print ''.join(chars) !dlroW olleH The .forw is so you can use anonymous sequences in __init__, and still keep a reference the forward sequence. ) If you give it a non-anonymous mutable sequence, the reverse sequence will track the updated values. ( but not reassignment! - another good reason to use anonymous values in creating the sequence to avoid confusion. Maybe it should be change to copy input sequence to break the connection completely ? ) >>> nnn = range(3) >>> rnn = Rev(nnn) >>> for n in rnn: print n ... 2 1 0 >>> for n in range(4, 6): nnn.append(n) # update nnn ... >>> for n in rnn: print n # prints reversed updated values ... 5 4 2 1 0 >>> nnn = nnn[1:-1] >>> nnn [1, 2, 4] >>> for n in rnn: print n # prints reversed values of old nnn ... 5 4 2 1 0 # >>> WH = Rev('Hello World!') >>> print WH.forw, WH.back Hello World! !dlroW olleH >>> nnn = Rev(range(1, 10)) >>> print nnn.forw [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> print nnn.back [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> rrr = Rev(nnn) >>> rrr <1, 2, 3, 4, 5, 6, 7, 8, 9> ''' class Rev: def __init__(self, seq): self.forw = seq self.back = self def __len__(self): return len(self.forw) def __getitem__(self, j): return self.forw[-(j + 1)] def __repr__(self): seq = self.forw if isinstance(seq, list): wrap = '[]' sep = ', ' elif isinstance(seq, tuple): wrap = '()' sep = ', ' elif isinstance(seq, str): wrap = '' sep = '' else: wrap = '<>' sep = ', ' outstrs = [str(item) for item in self.back] return wrap[:1] + sep.join(outstrs) + wrap[-1:] def _test(): import doctest, Rev return doctest.testmod(Rev) if __name__ == "__main__": _test() PK1]1 1 Rev.pyonu[ ^c@s<dZdddYZdZedkr8endS(s A class which presents the reverse of a sequence without duplicating it. From: "Steven D. Majewski" It works on mutable or inmutable sequences. >>> chars = list(Rev('Hello World!')) >>> print ''.join(chars) !dlroW olleH The .forw is so you can use anonymous sequences in __init__, and still keep a reference the forward sequence. ) If you give it a non-anonymous mutable sequence, the reverse sequence will track the updated values. ( but not reassignment! - another good reason to use anonymous values in creating the sequence to avoid confusion. Maybe it should be change to copy input sequence to break the connection completely ? ) >>> nnn = range(3) >>> rnn = Rev(nnn) >>> for n in rnn: print n ... 2 1 0 >>> for n in range(4, 6): nnn.append(n) # update nnn ... >>> for n in rnn: print n # prints reversed updated values ... 5 4 2 1 0 >>> nnn = nnn[1:-1] >>> nnn [1, 2, 4] >>> for n in rnn: print n # prints reversed values of old nnn ... 5 4 2 1 0 # >>> WH = Rev('Hello World!') >>> print WH.forw, WH.back Hello World! !dlroW olleH >>> nnn = Rev(range(1, 10)) >>> print nnn.forw [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> print nnn.back [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> rrr = Rev(nnn) >>> rrr <1, 2, 3, 4, 5, 6, 7, 8, 9> tRevcBs,eZdZdZdZdZRS(cCs||_||_dS(N(tforwtback(tselftseq((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__init__?s cCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__len__CscCs|j|d S(Ni(R(Rtj((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt __getitem__FscCs|j}t|tr'd}d}nHt|trEd}d}n*t|trcd}d}n d}d}g|jD]}t|^qy}|d |j||dS(Ns[]s, s()ts<>ii(Rt isinstancetlistttupletstrRtjoin(RRtwraptseptitemtoutstrs((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__repr__Is    "(t__name__t __module__RRR R(((s(/usr/lib64/python2.7/Demo/classes/Rev.pyR>s   cCs%ddl}ddl}|j|S(Ni(tdoctestRttestmod(RR((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt_testZst__main__N((t__doc__RRR(((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt<s  PK1]E Range.pyonu[ ^c@sNdZdZdZdddYZdZedkrJendS( s Example of a generator: re-implement the built-in range function without actually constructing the list of values. OldStyleRange is coded in the way required to work in a 'for' loop before iterators were introduced into the language; using __getitem__ and __len__ . cCsyt|dkr,dt|ddfSt|dkr_t|dt|ddfSt|dkr|ddkrtdntd|DStdt|Wntk rtdnXd S( sgTake list of arguments and extract/create proper start, stop, and step values and return in a tupleiiiisstep argument must not be zerocss|]}t|VqdS(N(tint(t.0tx((s*/usr/lib64/python2.7/Demo/classes/Range.pys ss$range() accepts 1-3 arguments, givensArange() arguments must be numbers or strings representing numbersN(tlenRt ValueErrorttuplet TypeError(targlist((s*/usr/lib64/python2.7/Demo/classes/Range.pyt handleargss! cgsAt|\}}}|}x||kr<|V||7}qWdS(s,Function to implement 'range' as a generatorN(R(tatstarttstoptsteptvalue((s*/usr/lib64/python2.7/Demo/classes/Range.pytgenranges toldrangecBs2eZdZdZdZdZdZRS(sClass implementing a range object. To the user the instances feel like immutable sequences (and you can't concatenate or slice them) Done using the old way (pre-iterators; __len__ and __getitem__) to have an object be used by a 'for' loop. cGsEt|\|_|_|_td|j|j|j|_dS(s Initialize start, stop, and step values along with calculating the nubmer of values (what __len__ will return) in the rangeiN(RR R R tmaxR(tselfR ((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__init__,scCsd|j|j|jfS(s-implement repr(x) which is also used by printsrange(%r, %r, %r)(R R R (R((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__repr__2scCs|jS(simplement len(x)(R(R((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__len__6scCs>d|ko|jknr1|j|j|StddS(simplement x[i]isrange[i] index out of rangeN(RR R t IndexError(Rti((s*/usr/lib64/python2.7/Demo/classes/Range.pyt __getitem__:s(t__name__t __module__t__doc__RRRR(((s*/usr/lib64/python2.7/Demo/classes/Range.pyR"s    c Cs9ddl}ddl}|jddd}ttddd}ttddd}||ksu||krtd|||fndGH|j}xtdD]}qW|j}xtdD]}qW|j}x|jdD]}qW|j} ||GdGH||Gd GH| |Gd GHdS( NiiidisEerror in implementation: correct = %s old-style = %s generator = %ssTimings for range(1000):issec (old-style class)ssec (generator)ssec (built-in)(ttimet __builtin__trangetlistRRt Exception( RRtcorrect_resulttoldrange_resulttgenrange_resulttt1Rtt2tt3tt4((s*/usr/lib64/python2.7/Demo/classes/Range.pyttestBs*      t__main__N((RRRRR'R(((s*/usr/lib64/python2.7/Demo/classes/Range.pyts     PK1]E Range.pycnu[ ^c@sNdZdZdZdddYZdZedkrJendS( s Example of a generator: re-implement the built-in range function without actually constructing the list of values. OldStyleRange is coded in the way required to work in a 'for' loop before iterators were introduced into the language; using __getitem__ and __len__ . cCsyt|dkr,dt|ddfSt|dkr_t|dt|ddfSt|dkr|ddkrtdntd|DStdt|Wntk rtdnXd S( sgTake list of arguments and extract/create proper start, stop, and step values and return in a tupleiiiisstep argument must not be zerocss|]}t|VqdS(N(tint(t.0tx((s*/usr/lib64/python2.7/Demo/classes/Range.pys ss$range() accepts 1-3 arguments, givensArange() arguments must be numbers or strings representing numbersN(tlenRt ValueErrorttuplet TypeError(targlist((s*/usr/lib64/python2.7/Demo/classes/Range.pyt handleargss! cgsAt|\}}}|}x||kr<|V||7}qWdS(s,Function to implement 'range' as a generatorN(R(tatstarttstoptsteptvalue((s*/usr/lib64/python2.7/Demo/classes/Range.pytgenranges toldrangecBs2eZdZdZdZdZdZRS(sClass implementing a range object. To the user the instances feel like immutable sequences (and you can't concatenate or slice them) Done using the old way (pre-iterators; __len__ and __getitem__) to have an object be used by a 'for' loop. cGsEt|\|_|_|_td|j|j|j|_dS(s Initialize start, stop, and step values along with calculating the nubmer of values (what __len__ will return) in the rangeiN(RR R R tmaxR(tselfR ((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__init__,scCsd|j|j|jfS(s-implement repr(x) which is also used by printsrange(%r, %r, %r)(R R R (R((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__repr__2scCs|jS(simplement len(x)(R(R((s*/usr/lib64/python2.7/Demo/classes/Range.pyt__len__6scCs>d|ko|jknr1|j|j|StddS(simplement x[i]isrange[i] index out of rangeN(RR R t IndexError(Rti((s*/usr/lib64/python2.7/Demo/classes/Range.pyt __getitem__:s(t__name__t __module__t__doc__RRRR(((s*/usr/lib64/python2.7/Demo/classes/Range.pyR"s    c Cs9ddl}ddl}|jddd}ttddd}ttddd}||ksu||krtd|||fndGH|j}xtdD]}qW|j}xtdD]}qW|j}x|jdD]}qW|j} ||GdGH||Gd GH| |Gd GHdS( NiiidisEerror in implementation: correct = %s old-style = %s generator = %ssTimings for range(1000):issec (old-style class)ssec (generator)ssec (built-in)(ttimet __builtin__trangetlistRRt Exception( RRtcorrect_resulttoldrange_resulttgenrange_resulttt1Rtt2tt3tt4((s*/usr/lib64/python2.7/Demo/classes/Range.pyttestBs*      t__main__N((RRRRR'R(((s*/usr/lib64/python2.7/Demo/classes/Range.pyts     PK1]FI&'&' Complex.pyonu[ ^c@sddlZddlZejdZejdZdZdZddedZdZdZ d dd YZ d Z d d Z dZ edkre ndS(iNg@cCst|dot|dS(Ntretim(thasattr(tobj((s,/usr/lib64/python2.7/Demo/classes/Complex.pyt IsComplexGscCs7t|r|St|tr)t|St|SdS(N(Rt isinstancettupletComplex(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pyt ToComplexJs   icCs5|t|}ttj||tj||S(N(ttwopiRtmathtcostsin(trtphit fullcircle((s,/usr/lib64/python2.7/Demo/classes/Complex.pytPolarToComplexRscCst|r|jS|S(N(RR(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pytReVs cCst|r|jSdS(Ni(RR(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pytIm[s RcBseZdddZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZe ZZedZeZdZeZdZdZdZeZdZdZddZdZRS(icCsd}d}t|r-|j}|j}n|}t|r\||j}||j}n ||}||jd<||jdcCsdG|GdG|Gyt|}Wntj}nXdG|GHt|tsZt|tri||k}nt|||k}|sdG|GdGt||GHndS(Ns tands->s!! !! !! should betdiff(tevaltsystexc_typeRtstrR@(texprtatbRtfuzztresulttok((s,/usr/lib64/python2.7/Demo/classes/Complex.pytcheckops  cCsdGHdtfd tfd!tdfd"tddfd#ttddfd$ttdddfd%tdtddfd&tdtdfd'tdtddfd(ttddtdd ff }ddg}x|D]x}|dcd7<|dd|djksH|dd|djkrd G|dGd G|dGH|dcd7As           J PK1](  READMEnu[Examples of classes that implement special operators (see reference manual): Complex.py Complex numbers Dates.py Date manipulation package by Tim Peters Dbm.py Wrapper around built-in dbm, supporting arbitrary values Range.py Example of a generator: re-implement built-in range() Rev.py Yield the reverse of a sequence Vec.py A simple vector class bitvec.py A bit-vector class by Jan-Hein B\"uhrman (For straightforward examples of basic class features, such as use of methods and inheritance, see the library code.) PK1]ΎMMVec.pynu[class Vec: """ A simple vector class Instances of the Vec class can be constructed from numbers >>> a = Vec(1, 2, 3) >>> b = Vec(3, 2, 1) added >>> a + b Vec(4, 4, 4) subtracted >>> a - b Vec(-2, 0, 2) and multiplied by a scalar on the left >>> 3.0 * a Vec(3.0, 6.0, 9.0) or on the right >>> a * 3.0 Vec(3.0, 6.0, 9.0) """ def __init__(self, *v): self.v = list(v) @classmethod def fromlist(cls, v): if not isinstance(v, list): raise TypeError inst = cls() inst.v = v return inst def __repr__(self): args = ', '.join(repr(x) for x in self.v) return 'Vec({0})'.format(args) def __len__(self): return len(self.v) def __getitem__(self, i): return self.v[i] def __add__(self, other): # Element-wise addition v = [x + y for x, y in zip(self.v, other.v)] return Vec.fromlist(v) def __sub__(self, other): # Element-wise subtraction v = [x - y for x, y in zip(self.v, other.v)] return Vec.fromlist(v) def __mul__(self, scalar): # Multiply by scalar v = [x * scalar for x in self.v] return Vec.fromlist(v) __rmul__ = __mul__ def test(): import doctest doctest.testmod() test() PK1]w Dates.pyonu[ ^c @spdddddddddd d d g Zd d dddddgZddddddddddddg ZgZdZx%eD]ZejeeeZqW[[ededfZdZ dZ dZ dZ dZ dZe dZd Zd!Zd"d,d#YZd$Zd%efd&YZd'Zed(krled)d*nd+S(-tJanuarytFebruarytMarchtApriltMaytJunetJulytAugustt SeptembertOctobertNovembertDecembertFridaytSaturdaytSundaytMondaytTuesdayt WednesdaytThursdayiiiiilcCs6|ddkrdS|ddkr(dS|ddkS(Niiiiid((tyear((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_is_leap>s cCsdt|S(Nim(R(R((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _days_in_yearCscCs,|d|dd|dd|ddS(Nlmiiicidii((R((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_before_yearFscCs(|dkrt|rdSt|dS(Niii(Rt_DAYS_IN_MONTH(tmonthR((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_in_monthIscCs"t|d|dko t|S(Nii(t_DAYS_BEFORE_MONTHR(RR((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_before_monthMscCs't|jt|j|j|jS(N(RRRRtday(tdate((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _date2numPsicCs}t|tkr(tdt|ntddd}|`|`|`|`||_|dt}d||t|}}|d}t |}||kr|d}|t |}n||t ||}}yt |}Wnt t fk rnXt|ddd}t||}||krX|d}|t||}n|||||_|_|_|S(Nsargument must be integer: %riiimii (ttypet _INT_TYPESt TypeErrortDatetordRRRt_DI400YRRtintt ValueErrort OverflowErrortminRR(tntanstn400RtmoretdbyRtdbm((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _num2dateWs0       !cCstt|dS(Ni(t _DAY_NAMESR%(R)((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_num2daytsR"cBs_eZdZdZdZdZdZdZeZdZ dZ dZ RS( cCsd|kodkns/td|fnt||}d|koU|knsptd||fn||||_|_|_t||_dS(Nii smonth must be in 1..12: %rsday must be in 1..%r: %r(R&RRRRRR#(tselfRRRtdim((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt__init__yscCs3|jj|r"td|n||j|num failedsnum->date failed(R"treprRMR!R@tmaxR(RRR#R/RRR( t firstyeartlastyeartatbtxtdtlordtytfordtfdtld((s*/usr/lib64/python2.7/Demo/classes/Dates.pyttestsP 1            * 8   %-t__main__i:ifN((RAR0RRR.R3tappendRR RRRRRRR$R/R1R"RLt ExceptionRMR[RF(((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt,s6  *           4  . PK1]cAC<5(5( bitvec.pycnu[ ^c@s{ddlZejjZdefdYZdZddlZdZdZ dZ dfd YZ e Z dS( iNterrorcBseZRS((t__name__t __module__(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR scCsEt|tdks5d|ko/dkn rAtdndS(Niis)bitvec() items must have int value 0 or 1(ttypeR(tvalue((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_value s5cCstjt|\}}d|>}||krMtd||ffnx,|r{|d?}||@rnPn|d}qPW|S(Nls(param, l) = %ri(tmathtfrexptfloatt RuntimeError(tparamtmanttltbitmask((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _compute_lens     cCsit|tdkr$tdn|dkr=||}nd|koT|knsetdn|S(Nissequence subscript not intslist index out of range(Rt TypeErrort IndexError(tlentkey((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_key!s    cCs>t|dt||}}||kr4|}n||fS(Ni(tmaxtmin(Rtitj((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_slice*s  tBitVeccBs eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cGsd|_d|_t|s!nt|dkr|\}t|tgkrd}d}x+|D]#}|r||B}n|d>}qgW||_t||_qt|tdkr|dkrtdn||_t||_qtdnt|dkr|\}}t|tdkr|dkrNtdn||_t|tdkr{td nt|}||krd GH|jd|>d@|_n||_qtdn td dS( Nliils$bitvec() can't handle negative longss)bitvec() requires array or long parameteriscan't handle negative longss$bitvec()'s 2nd parameter must be intsMwarning: bitvec() value is longer than the length indicates, truncating values%bitvec() requires 0 -- 2 parameter(s)(t_datat_lenRRRR(tselftparamsR Rtbit_masktitemtlengthtcomputed_length((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__init__4sL                    cCs(tt| d||j|j+dS(Ni(RtlongR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytappendbscCsR|r|j}n |j}d}x)|rM|d?||d@dk}}q%W|S(Nii(R(RRtdatatcount((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR&is   #cCs^|r|j}n |j}d}|s4tdnx#|d@sY|d?|d}}q7W|S(Nislist.index(x): x not in listi(Rt ValueError(RRR%tindex((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR(us    cCs"tt| d|||+dS(Ni(RR#(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytinsertscCs||j|=dS(N(R((RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytremovescCso|jd}}xOt|jD]>}|sA||j|>}Pn|d>|d@B|d?}}q W||_dS(Nli(RtrangeR(RR%tresultR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytreverses!cCs/|jd}d|>d|j|>|_dS(Nil(R&RR(Rtc((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytsortscCst|j|jS(N(RRR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytcopyscCs(g}x|D]}|j|q W|S(N(R$(RR,R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytseqs cCsd|j|jfS(Nsbitvec(%r, %r)(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__repr__scGs#t|t|kr1tt|f|}n|j}|dksU|jdkret||jS||jkrt||j}t|| || pt||||S|j|jkrdS|dkrt|d|dS|d?}t|| || pt||||SdS(Nii(RtapplytbitvecRtcmpRR(RtothertrestR t min_length((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__cmp__s    cCs|jS(N(R(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__len__scCs't|j|}|jd|>@dkS(Nli(RRR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __getitem__scCsHt|j|}|r/|jd|>B|_n|jd|>@|_dS(Nl(RRR(RRR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __setitem__scCsIt|j|}|| j||dj|?B|_|jd|_dS(Ni(RRR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __delitem__s#cCst|j||\}}||kr4tddS|rJ|j|?}n |j}||}||jkr|d|>d@}nt||S(Nlili(RRRR(RRRtndatatnlength((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __getslice__s    cGst|j||\}}t|t|krLtt|f|}n|| }||}|j|j|j|j>B|j>B|_|j|||j|_dS(N(RRRR3R4R(RRRtsequenceR7tls_parttms_part((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __setslice__s  cCst|j||\}}|dkrK||jkrKd\|_|_nB||kr|| j||j|?B|_|j|||_ndS(Nil(li(RRR(RRR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __delslice__s  cCs#|j}|||j|j+|S(N(R0R(RR6tretval((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__add__s cCst|tdkr$tdn|dkr=tddS|dkrS|jS|jdkrvtd|j|S|jdkrtd|j|Stdd}x|r|||d}}qW|S(Nissequence subscript not intli(RRRR0RR(Rt multiplierRF((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__mul__ s      cGsWt|t|kr1tt|f|}nt|j|j@t|j|jS(N(RR3R4RRRR(RtotherseqR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__and__scGsWt|t|kr1tt|f|}nt|j|jAt|j|jS(N(RR3R4RRRR(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__xor__%scGsWt|t|kr1tt|f|}nt|j|jBt|j|jS(N(RR3R4RRRR(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__or__.scCs#t|jd|j>d@|jS(Nli(RRR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __invert__7scGs;t|t|kr1tt|f|}n||fS(N(RR3R4(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __coerce__<scCs t|jS(N(tintR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__int__CscCs t|jS(N(R#R(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__long__FscCs t|jS(N(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __float__Is(RRR"R$R&R(R)R*R-R/R0R1R2R9R:R;R<R=R@RDRERGRIRKRLRMRNRORQRRRS(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR2s: .                   ( tsyststderrtwritetrprtt ExceptionRRRRRRRR4(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyts    PK1]cAC<5(5( bitvec.pyonu[ ^c@s{ddlZejjZdefdYZdZddlZdZdZ dZ dfd YZ e Z dS( iNterrorcBseZRS((t__name__t __module__(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR scCsEt|tdks5d|ko/dkn rAtdndS(Niis)bitvec() items must have int value 0 or 1(ttypeR(tvalue((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_value s5cCstjt|\}}d|>}||krMtd||ffnx,|r{|d?}||@rnPn|d}qPW|S(Nls(param, l) = %ri(tmathtfrexptfloatt RuntimeError(tparamtmanttltbitmask((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _compute_lens     cCsit|tdkr$tdn|dkr=||}nd|koT|knsetdn|S(Nissequence subscript not intslist index out of range(Rt TypeErrort IndexError(tlentkey((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_key!s    cCs>t|dt||}}||kr4|}n||fS(Ni(tmaxtmin(Rtitj((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt _check_slice*s  tBitVeccBs eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cGsd|_d|_t|s!nt|dkr|\}t|tgkrd}d}x+|D]#}|r||B}n|d>}qgW||_t||_qt|tdkr|dkrtdn||_t||_qtdnt|dkr|\}}t|tdkr|dkrNtdn||_t|tdkr{td nt|}||krd GH|jd|>d@|_n||_qtdn td dS( Nliils$bitvec() can't handle negative longss)bitvec() requires array or long parameteriscan't handle negative longss$bitvec()'s 2nd parameter must be intsMwarning: bitvec() value is longer than the length indicates, truncating values%bitvec() requires 0 -- 2 parameter(s)(t_datat_lenRRRR(tselftparamsR Rtbit_masktitemtlengthtcomputed_length((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__init__4sL                    cCs(tt| d||j|j+dS(Ni(RtlongR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytappendbscCsR|r|j}n |j}d}x)|rM|d?||d@dk}}q%W|S(Nii(R(RRtdatatcount((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR&is   #cCs^|r|j}n |j}d}|s4tdnx#|d@sY|d?|d}}q7W|S(Nislist.index(x): x not in listi(Rt ValueError(RRR%tindex((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR(us    cCs"tt| d|||+dS(Ni(RR#(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytinsertscCs||j|=dS(N(R((RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytremovescCso|jd}}xOt|jD]>}|sA||j|>}Pn|d>|d@B|d?}}q W||_dS(Nli(RtrangeR(RR%tresultR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytreverses!cCs/|jd}d|>d|j|>|_dS(Nil(R&RR(Rtc((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytsortscCst|j|jS(N(RRR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytcopyscCs(g}x|D]}|j|q W|S(N(R$(RR,R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pytseqs cCsd|j|jfS(Nsbitvec(%r, %r)(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__repr__scGs#t|t|kr1tt|f|}n|j}|dksU|jdkret||jS||jkrt||j}t|| || pt||||S|j|jkrdS|dkrt|d|dS|d?}t|| || pt||||SdS(Nii(RtapplytbitvecRtcmpRR(RtothertrestR t min_length((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__cmp__s    cCs|jS(N(R(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__len__scCs't|j|}|jd|>@dkS(Nli(RRR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __getitem__scCsHt|j|}|r/|jd|>B|_n|jd|>@|_dS(Nl(RRR(RRR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __setitem__scCsIt|j|}|| j||dj|?B|_|jd|_dS(Ni(RRR(RR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __delitem__s#cCst|j||\}}||kr4tddS|rJ|j|?}n |j}||}||jkr|d|>d@}nt||S(Nlili(RRRR(RRRtndatatnlength((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __getslice__s    cGst|j||\}}t|t|krLtt|f|}n|| }||}|j|j|j|j>B|j>B|_|j|||j|_dS(N(RRRR3R4R(RRRtsequenceR7tls_parttms_part((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __setslice__s  cCst|j||\}}|dkrK||jkrKd\|_|_nB||kr|| j||j|?B|_|j|||_ndS(Nil(li(RRR(RRR((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __delslice__s  cCs#|j}|||j|j+|S(N(R0R(RR6tretval((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__add__s cCst|tdkr$tdn|dkr=tddS|dkrS|jS|jdkrvtd|j|S|jdkrtd|j|Stdd}x|r|||d}}qW|S(Nissequence subscript not intli(RRRR0RR(Rt multiplierRF((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__mul__ s      cGsWt|t|kr1tt|f|}nt|j|j@t|j|jS(N(RR3R4RRRR(RtotherseqR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__and__scGsWt|t|kr1tt|f|}nt|j|jAt|j|jS(N(RR3R4RRRR(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__xor__%scGsWt|t|kr1tt|f|}nt|j|jBt|j|jS(N(RR3R4RRRR(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__or__.scCs#t|jd|j>d@|jS(Nli(RRR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __invert__7scGs;t|t|kr1tt|f|}n||fS(N(RR3R4(RRJR7((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __coerce__<scCs t|jS(N(tintR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__int__CscCs t|jS(N(R#R(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt__long__FscCs t|jS(N(RR(R((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyt __float__Is(RRR"R$R&R(R)R*R-R/R0R1R2R9R:R;R<R=R@RDRERGRIRKRLRMRNRORQRRRS(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyR2s: .                   ( tsyststderrtwritetrprtt ExceptionRRRRRRRR4(((s+/usr/lib64/python2.7/Demo/classes/bitvec.pyts    PK1]:6  Vec.pyonu[ ^c@s'dddYZdZedS(tVeccBsbeZdZdZedZdZdZdZdZ dZ dZ e Z RS( sx A simple vector class Instances of the Vec class can be constructed from numbers >>> a = Vec(1, 2, 3) >>> b = Vec(3, 2, 1) added >>> a + b Vec(4, 4, 4) subtracted >>> a - b Vec(-2, 0, 2) and multiplied by a scalar on the left >>> 3.0 * a Vec(3.0, 6.0, 9.0) or on the right >>> a * 3.0 Vec(3.0, 6.0, 9.0) cGst||_dS(N(tlisttv(tselfR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__init__scCs.t|tstn|}||_|S(N(t isinstanceRt TypeErrorR(tclsRtinst((s(/usr/lib64/python2.7/Demo/classes/Vec.pytfromlists    cCs)djd|jD}dj|S(Ns, css|]}t|VqdS(N(trepr(t.0tx((s(/usr/lib64/python2.7/Demo/classes/Vec.pys %ssVec({0})(tjoinRtformat(Rtargs((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__repr__$scCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__len__(scCs |j|S(N(R(Rti((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt __getitem__+scCs?gt|j|jD]\}}||^q}tj|S(N(tzipRRR (RtotherR tyR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__add__.s2cCs?gt|j|jD]\}}||^q}tj|S(N(RRRR (RRR RR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__sub__3s2cCs-g|jD]}||^q }tj|S(N(RRR (RtscalarR R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__mul__8s ( t__name__t __module__t__doc__Rt classmethodR RRRRRRt__rmul__(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyRs       cCsddl}|jdS(Ni(tdoctestttestmod(R!((s(/usr/lib64/python2.7/Demo/classes/Vec.pyttest@s N((RR#(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyts? PK1]u+&& Complex.pynu[# Complex numbers # --------------- # [Now that Python has a complex data type built-in, this is not very # useful, but it's still a nice example class] # This module represents complex numbers as instances of the class Complex. # A Complex instance z has two data attribues, z.re (the real part) and z.im # (the imaginary part). In fact, z.re and z.im can have any value -- all # arithmetic operators work regardless of the type of z.re and z.im (as long # as they support numerical operations). # # The following functions exist (Complex is actually a class): # Complex([re [,im]) -> creates a complex number from a real and an imaginary part # IsComplex(z) -> true iff z is a complex number (== has .re and .im attributes) # ToComplex(z) -> a complex number equal to z; z itself if IsComplex(z) is true # if z is a tuple(re, im) it will also be converted # PolarToComplex([r [,phi [,fullcircle]]]) -> # the complex number z for which r == z.radius() and phi == z.angle(fullcircle) # (r and phi default to 0) # exp(z) -> returns the complex exponential of z. Equivalent to pow(math.e,z). # # Complex numbers have the following methods: # z.abs() -> absolute value of z # z.radius() == z.abs() # z.angle([fullcircle]) -> angle from positive X axis; fullcircle gives units # z.phi([fullcircle]) == z.angle(fullcircle) # # These standard functions and unary operators accept complex arguments: # abs(z) # -z # +z # not z # repr(z) == `z` # str(z) # hash(z) -> a combination of hash(z.re) and hash(z.im) such that if z.im is zero # the result equals hash(z.re) # Note that hex(z) and oct(z) are not defined. # # These conversions accept complex arguments only if their imaginary part is zero: # int(z) # long(z) # float(z) # # The following operators accept two complex numbers, or one complex number # and one real number (int, long or float): # z1 + z2 # z1 - z2 # z1 * z2 # z1 / z2 # pow(z1, z2) # cmp(z1, z2) # Note that z1 % z2 and divmod(z1, z2) are not defined, # nor are shift and mask operations. # # The standard module math does not support complex numbers. # The cmath modules should be used instead. # # Idea: # add a class Polar(r, phi) and mixed-mode arithmetic which # chooses the most appropriate type for the result: # Complex for +,-,cmp # Polar for *,/,pow import math import sys twopi = math.pi*2.0 halfpi = math.pi/2.0 def IsComplex(obj): return hasattr(obj, 're') and hasattr(obj, 'im') def ToComplex(obj): if IsComplex(obj): return obj elif isinstance(obj, tuple): return Complex(*obj) else: return Complex(obj) def PolarToComplex(r = 0, phi = 0, fullcircle = twopi): phi = phi * (twopi / fullcircle) return Complex(math.cos(phi)*r, math.sin(phi)*r) def Re(obj): if IsComplex(obj): return obj.re return obj def Im(obj): if IsComplex(obj): return obj.im return 0 class Complex: def __init__(self, re=0, im=0): _re = 0 _im = 0 if IsComplex(re): _re = re.re _im = re.im else: _re = re if IsComplex(im): _re = _re - im.im _im = _im + im.re else: _im = _im + im # this class is immutable, so setting self.re directly is # not possible. self.__dict__['re'] = _re self.__dict__['im'] = _im def __setattr__(self, name, value): raise TypeError, 'Complex numbers are immutable' def __hash__(self): if not self.im: return hash(self.re) return hash((self.re, self.im)) def __repr__(self): if not self.im: return 'Complex(%r)' % (self.re,) else: return 'Complex(%r, %r)' % (self.re, self.im) def __str__(self): if not self.im: return repr(self.re) else: return 'Complex(%r, %r)' % (self.re, self.im) def __neg__(self): return Complex(-self.re, -self.im) def __pos__(self): return self def __abs__(self): return math.hypot(self.re, self.im) def __int__(self): if self.im: raise ValueError, "can't convert Complex with nonzero im to int" return int(self.re) def __long__(self): if self.im: raise ValueError, "can't convert Complex with nonzero im to long" return long(self.re) def __float__(self): if self.im: raise ValueError, "can't convert Complex with nonzero im to float" return float(self.re) def __cmp__(self, other): other = ToComplex(other) return cmp((self.re, self.im), (other.re, other.im)) def __rcmp__(self, other): other = ToComplex(other) return cmp(other, self) def __nonzero__(self): return not (self.re == self.im == 0) abs = radius = __abs__ def angle(self, fullcircle = twopi): return (fullcircle/twopi) * ((halfpi - math.atan2(self.re, self.im)) % twopi) phi = angle def __add__(self, other): other = ToComplex(other) return Complex(self.re + other.re, self.im + other.im) __radd__ = __add__ def __sub__(self, other): other = ToComplex(other) return Complex(self.re - other.re, self.im - other.im) def __rsub__(self, other): other = ToComplex(other) return other - self def __mul__(self, other): other = ToComplex(other) return Complex(self.re*other.re - self.im*other.im, self.re*other.im + self.im*other.re) __rmul__ = __mul__ def __div__(self, other): other = ToComplex(other) d = float(other.re*other.re + other.im*other.im) if not d: raise ZeroDivisionError, 'Complex division' return Complex((self.re*other.re + self.im*other.im) / d, (self.im*other.re - self.re*other.im) / d) def __rdiv__(self, other): other = ToComplex(other) return other / self def __pow__(self, n, z=None): if z is not None: raise TypeError, 'Complex does not support ternary pow()' if IsComplex(n): if n.im: if self.im: raise TypeError, 'Complex to the Complex power' else: return exp(math.log(self.re)*n) n = n.re r = pow(self.abs(), n) phi = n*self.angle() return Complex(math.cos(phi)*r, math.sin(phi)*r) def __rpow__(self, base): base = ToComplex(base) return pow(base, self) def exp(z): r = math.exp(z.re) return Complex(math.cos(z.im)*r,math.sin(z.im)*r) def checkop(expr, a, b, value, fuzz = 1e-6): print ' ', a, 'and', b, try: result = eval(expr) except: result = sys.exc_type print '->', result if isinstance(result, str) or isinstance(value, str): ok = (result == value) else: ok = abs(result - value) <= fuzz if not ok: print '!!\t!!\t!! should be', value, 'diff', abs(result - value) def test(): print 'test constructors' constructor_test = ( # "expect" is an array [re,im] "got" the Complex. ( (0,0), Complex() ), ( (0,0), Complex() ), ( (1,0), Complex(1) ), ( (0,1), Complex(0,1) ), ( (1,2), Complex(Complex(1,2)) ), ( (1,3), Complex(Complex(1,2),1) ), ( (0,0), Complex(0,Complex(0,0)) ), ( (3,4), Complex(3,Complex(4)) ), ( (-1,3), Complex(1,Complex(3,2)) ), ( (-7,6), Complex(Complex(1,2),Complex(4,8)) ) ) cnt = [0,0] for t in constructor_test: cnt[0] += 1 if ((t[0][0]!=t[1].re)or(t[0][1]!=t[1].im)): print " expected", t[0], "got", t[1] cnt[1] += 1 print " ", cnt[1], "of", cnt[0], "tests failed" # test operators testsuite = { 'a+b': [ (1, 10, 11), (1, Complex(0,10), Complex(1,10)), (Complex(0,10), 1, Complex(1,10)), (Complex(0,10), Complex(1), Complex(1,10)), (Complex(1), Complex(0,10), Complex(1,10)), ], 'a-b': [ (1, 10, -9), (1, Complex(0,10), Complex(1,-10)), (Complex(0,10), 1, Complex(-1,10)), (Complex(0,10), Complex(1), Complex(-1,10)), (Complex(1), Complex(0,10), Complex(1,-10)), ], 'a*b': [ (1, 10, 10), (1, Complex(0,10), Complex(0, 10)), (Complex(0,10), 1, Complex(0,10)), (Complex(0,10), Complex(1), Complex(0,10)), (Complex(1), Complex(0,10), Complex(0,10)), ], 'a/b': [ (1., 10, 0.1), (1, Complex(0,10), Complex(0, -0.1)), (Complex(0, 10), 1, Complex(0, 10)), (Complex(0, 10), Complex(1), Complex(0, 10)), (Complex(1), Complex(0,10), Complex(0, -0.1)), ], 'pow(a,b)': [ (1, 10, 1), (1, Complex(0,10), 1), (Complex(0,10), 1, Complex(0,10)), (Complex(0,10), Complex(1), Complex(0,10)), (Complex(1), Complex(0,10), 1), (2, Complex(4,0), 16), ], 'cmp(a,b)': [ (1, 10, -1), (1, Complex(0,10), 1), (Complex(0,10), 1, -1), (Complex(0,10), Complex(1), -1), (Complex(1), Complex(0,10), 1), ], } for expr in sorted(testsuite): print expr + ':' t = (expr,) for item in testsuite[expr]: checkop(*(t+item)) if __name__ == '__main__': test() PK1]/ Dates.pynu[# Class Date supplies date objects that support date arithmetic. # # Date(month,day,year) returns a Date object. An instance prints as, # e.g., 'Mon 16 Aug 1993'. # # Addition, subtraction, comparison operators, min, max, and sorting # all work as expected for date objects: int+date or date+int returns # the date `int' days from `date'; date+date raises an exception; # date-int returns the date `int' days before `date'; date2-date1 returns # an integer, the number of days from date1 to date2; int-date raises an # exception; date1 < date2 is true iff date1 occurs before date2 (& # similarly for other comparisons); min(date1,date2) is the earlier of # the two dates and max(date1,date2) the later; and date objects can be # used as dictionary keys. # # Date objects support one visible method, date.weekday(). This returns # the day of the week the date falls on, as a string. # # Date objects also have 4 read-only data attributes: # .month in 1..12 # .day in 1..31 # .year int or long int # .ord the ordinal of the date relative to an arbitrary staring point # # The Dates module also supplies function today(), which returns the # current date as a date object. # # Those entranced by calendar trivia will be disappointed, as no attempt # has been made to accommodate the Julian (etc) system. On the other # hand, at least this package knows that 2000 is a leap year but 2100 # isn't, and works fine for years with a hundred decimal digits . # Tim Peters tim@ksr.com # not speaking for Kendall Square Research Corp # Adapted to Python 1.1 (where some hacks to overcome coercion are unnecessary) # by Guido van Rossum # Note that as of Python 2.3, a datetime module is included in the stardard # library. # vi:set tabsize=8: _MONTH_NAMES = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] _DAY_NAMES = [ 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' ] _DAYS_IN_MONTH = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] _DAYS_BEFORE_MONTH = [] dbm = 0 for dim in _DAYS_IN_MONTH: _DAYS_BEFORE_MONTH.append(dbm) dbm = dbm + dim del dbm, dim _INT_TYPES = type(1), type(1L) def _is_leap(year): # 1 if leap year, else 0 if year % 4 != 0: return 0 if year % 400 == 0: return 1 return year % 100 != 0 def _days_in_year(year): # number of days in year return 365 + _is_leap(year) def _days_before_year(year): # number of days before year return year*365L + (year+3)//4 - (year+99)//100 + (year+399)//400 def _days_in_month(month, year): # number of days in month of year if month == 2 and _is_leap(year): return 29 return _DAYS_IN_MONTH[month-1] def _days_before_month(month, year): # number of days in year before month return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year)) def _date2num(date): # compute ordinal of date.month,day,year return _days_before_year(date.year) + \ _days_before_month(date.month, date.year) + \ date.day _DI400Y = _days_before_year(400) # number of days in 400 years def _num2date(n): # return date with ordinal n if type(n) not in _INT_TYPES: raise TypeError, 'argument must be integer: %r' % type(n) ans = Date(1,1,1) # arguments irrelevant; just getting a Date obj del ans.ord, ans.month, ans.day, ans.year # un-initialize it ans.ord = n n400 = (n-1)//_DI400Y # # of 400-year blocks preceding year, n = 400 * n400, n - _DI400Y * n400 more = n // 365 dby = _days_before_year(more) if dby >= n: more = more - 1 dby = dby - _days_in_year(more) year, n = year + more, int(n - dby) try: year = int(year) # chop to int, if it fits except (ValueError, OverflowError): pass month = min(n//29 + 1, 12) dbm = _days_before_month(month, year) if dbm >= n: month = month - 1 dbm = dbm - _days_in_month(month, year) ans.month, ans.day, ans.year = month, n-dbm, year return ans def _num2day(n): # return weekday name of day with ordinal n return _DAY_NAMES[ int(n % 7) ] class Date: def __init__(self, month, day, year): if not 1 <= month <= 12: raise ValueError, 'month must be in 1..12: %r' % (month,) dim = _days_in_month(month, year) if not 1 <= day <= dim: raise ValueError, 'day must be in 1..%r: %r' % (dim, day) self.month, self.day, self.year = month, day, year self.ord = _date2num(self) # don't allow setting existing attributes def __setattr__(self, name, value): if self.__dict__.has_key(name): raise AttributeError, 'read-only attribute ' + name self.__dict__[name] = value def __cmp__(self, other): return cmp(self.ord, other.ord) # define a hash function so dates can be used as dictionary keys def __hash__(self): return hash(self.ord) # print as, e.g., Mon 16 Aug 1993 def __repr__(self): return '%.3s %2d %.3s %r' % ( self.weekday(), self.day, _MONTH_NAMES[self.month-1], self.year) # Python 1.1 coerces neither int+date nor date+int def __add__(self, n): if type(n) not in _INT_TYPES: raise TypeError, 'can\'t add %r to date' % type(n) return _num2date(self.ord + n) __radd__ = __add__ # handle int+date # Python 1.1 coerces neither date-int nor date-date def __sub__(self, other): if type(other) in _INT_TYPES: # date-int return _num2date(self.ord - other) else: return self.ord - other.ord # date-date # complain about int-date def __rsub__(self, other): raise TypeError, 'Can\'t subtract date from integer' def weekday(self): return _num2day(self.ord) def today(): import time local = time.localtime(time.time()) return Date(local[1], local[2], local[0]) class DateTestError(Exception): pass def test(firstyear, lastyear): a = Date(9,30,1913) b = Date(9,30,1914) if repr(a) != 'Tue 30 Sep 1913': raise DateTestError, '__repr__ failure' if (not a < b) or a == b or a > b or b != b: raise DateTestError, '__cmp__ failure' if a+365 != b or 365+a != b: raise DateTestError, '__add__ failure' if b-a != 365 or b-365 != a: raise DateTestError, '__sub__ failure' try: x = 1 - a raise DateTestError, 'int-date should have failed' except TypeError: pass try: x = a + b raise DateTestError, 'date+date should have failed' except TypeError: pass if a.weekday() != 'Tuesday': raise DateTestError, 'weekday() failure' if max(a,b) is not b or min(a,b) is not a: raise DateTestError, 'min/max failure' d = {a-1:b, b:a+1} if d[b-366] != b or d[a+(b-a)] != Date(10,1,1913): raise DateTestError, 'dictionary failure' # verify date<->number conversions for first and last days for # all years in firstyear .. lastyear lord = _days_before_year(firstyear) y = firstyear while y <= lastyear: ford = lord + 1 lord = ford + _days_in_year(y) - 1 fd, ld = Date(1,1,y), Date(12,31,y) if (fd.ord,ld.ord) != (ford,lord): raise DateTestError, ('date->num failed', y) fd, ld = _num2date(ford), _num2date(lord) if (1,1,y,12,31,y) != \ (fd.month,fd.day,fd.year,ld.month,ld.day,ld.year): raise DateTestError, ('num->date failed', y) y = y + 1 if __name__ == '__main__': test(1850, 2150) PK1]FI&'&' Complex.pycnu[ ^c@sddlZddlZejdZejdZdZdZddedZdZdZ d dd YZ d Z d d Z dZ edkre ndS(iNg@cCst|dot|dS(Ntretim(thasattr(tobj((s,/usr/lib64/python2.7/Demo/classes/Complex.pyt IsComplexGscCs7t|r|St|tr)t|St|SdS(N(Rt isinstancettupletComplex(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pyt ToComplexJs   icCs5|t|}ttj||tj||S(N(ttwopiRtmathtcostsin(trtphit fullcircle((s,/usr/lib64/python2.7/Demo/classes/Complex.pytPolarToComplexRscCst|r|jS|S(N(RR(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pytReVs cCst|r|jSdS(Ni(RR(R((s,/usr/lib64/python2.7/Demo/classes/Complex.pytIm[s RcBseZdddZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZe ZZedZeZdZeZdZdZdZeZdZdZddZdZRS(icCsd}d}t|r-|j}|j}n|}t|r\||j}||j}n ||}||jd<||jdcCsdG|GdG|Gyt|}Wntj}nXdG|GHt|tsZt|tri||k}nt|||k}|sdG|GdGt||GHndS(Ns tands->s!! !! !! should betdiff(tevaltsystexc_typeRtstrR@(texprtatbRtfuzztresulttok((s,/usr/lib64/python2.7/Demo/classes/Complex.pytcheckops  cCsdGHdtfd tfd!tdfd"tddfd#ttddfd$ttdddfd%tdtddfd&tdtdfd'tdtddfd(ttddtdd ff }ddg}x|D]x}|dcd7<|dd|djksH|dd|djkrd G|dGd G|dGH|dcd7As           J PK1] Dbm.pyonu[ ^c@s'dddYZdZedS(tDbmcBsPeZdZdZdZdZdZdZdZdZ RS(cCs(ddl}|j||||_dS(Ni(tdbmtopentdb(tselftfilenametmodetpermR((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__init__ s cCsdd}xO|jD]A}t|dt||}|rJd|}n||}qWd|dS(Nts: s, t{t}(tkeystrepr(Rtstkeytt((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__repr__ s cCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt__len__scCst|jt|S(N(tevalRR (RR((s(/usr/lib64/python2.7/Demo/classes/Dbm.pyt __getitem__scCst||jt|s$ PK1]1 1 Rev.pycnu[ ^c@s<dZdddYZdZedkr8endS(s A class which presents the reverse of a sequence without duplicating it. From: "Steven D. Majewski" It works on mutable or inmutable sequences. >>> chars = list(Rev('Hello World!')) >>> print ''.join(chars) !dlroW olleH The .forw is so you can use anonymous sequences in __init__, and still keep a reference the forward sequence. ) If you give it a non-anonymous mutable sequence, the reverse sequence will track the updated values. ( but not reassignment! - another good reason to use anonymous values in creating the sequence to avoid confusion. Maybe it should be change to copy input sequence to break the connection completely ? ) >>> nnn = range(3) >>> rnn = Rev(nnn) >>> for n in rnn: print n ... 2 1 0 >>> for n in range(4, 6): nnn.append(n) # update nnn ... >>> for n in rnn: print n # prints reversed updated values ... 5 4 2 1 0 >>> nnn = nnn[1:-1] >>> nnn [1, 2, 4] >>> for n in rnn: print n # prints reversed values of old nnn ... 5 4 2 1 0 # >>> WH = Rev('Hello World!') >>> print WH.forw, WH.back Hello World! !dlroW olleH >>> nnn = Rev(range(1, 10)) >>> print nnn.forw [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> print nnn.back [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> rrr = Rev(nnn) >>> rrr <1, 2, 3, 4, 5, 6, 7, 8, 9> tRevcBs,eZdZdZdZdZRS(cCs||_||_dS(N(tforwtback(tselftseq((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__init__?s cCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__len__CscCs|j|d S(Ni(R(Rtj((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt __getitem__FscCs|j}t|tr'd}d}nHt|trEd}d}n*t|trcd}d}n d}d}g|jD]}t|^qy}|d |j||dS(Ns[]s, s()ts<>ii(Rt isinstancetlistttupletstrRtjoin(RRtwraptseptitemtoutstrs((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt__repr__Is    "(t__name__t __module__RRR R(((s(/usr/lib64/python2.7/Demo/classes/Rev.pyR>s   cCs%ddl}ddl}|j|S(Ni(tdoctestRttestmod(RR((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt_testZst__main__N((t__doc__RRR(((s(/usr/lib64/python2.7/Demo/classes/Rev.pyt<s  PK1]w Dates.pycnu[ ^c @spdddddddddd d d g Zd d dddddgZddddddddddddg ZgZdZx%eD]ZejeeeZqW[[ededfZdZ dZ dZ dZ dZ dZe dZd Zd!Zd"d,d#YZd$Zd%efd&YZd'Zed(krled)d*nd+S(-tJanuarytFebruarytMarchtApriltMaytJunetJulytAugustt SeptembertOctobertNovembertDecembertFridaytSaturdaytSundaytMondaytTuesdayt WednesdaytThursdayiiiiilcCs6|ddkrdS|ddkr(dS|ddkS(Niiiiid((tyear((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_is_leap>s cCsdt|S(Nim(R(R((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _days_in_yearCscCs,|d|dd|dd|ddS(Nlmiiicidii((R((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_before_yearFscCs(|dkrt|rdSt|dS(Niii(Rt_DAYS_IN_MONTH(tmonthR((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_in_monthIscCs"t|d|dko t|S(Nii(t_DAYS_BEFORE_MONTHR(RR((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_days_before_monthMscCs't|jt|j|j|jS(N(RRRRtday(tdate((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _date2numPsicCs}t|tkr(tdt|ntddd}|`|`|`|`||_|dt}d||t|}}|d}t |}||kr|d}|t |}n||t ||}}yt |}Wnt t fk rnXt|ddd}t||}||krX|d}|t||}n|||||_|_|_|S(Nsargument must be integer: %riiimii (ttypet _INT_TYPESt TypeErrortDatetordRRRt_DI400YRRtintt ValueErrort OverflowErrortminRR(tntanstn400RtmoretdbyRtdbm((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt _num2dateWs0       !cCstt|dS(Ni(t _DAY_NAMESR%(R)((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt_num2daytsR"cBs_eZdZdZdZdZdZdZeZdZ dZ dZ RS( cCsd|kodkns/td|fnt||}d|koU|knsptd||fn||||_|_|_t||_dS(Nii smonth must be in 1..12: %rsday must be in 1..%r: %r(R&RRRRRR#(tselfRRRtdim((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt__init__yscCs3|jj|r"td|n||j|num failedsnum->date failed(R"treprRMR!R@tmaxR(RRR#R/RRR( t firstyeartlastyeartatbtxtdtlordtytfordtfdtld((s*/usr/lib64/python2.7/Demo/classes/Dates.pyttestsP 1            * 8   %-t__main__i:ifN((RAR0RRR.R3tappendRR RRRRRRR$R/R1R"RLt ExceptionRMR[RF(((s*/usr/lib64/python2.7/Demo/classes/Dates.pyt,s6  *           4  . PK1]:6  Vec.pycnu[ ^c@s'dddYZdZedS(tVeccBsbeZdZdZedZdZdZdZdZ dZ dZ e Z RS( sx A simple vector class Instances of the Vec class can be constructed from numbers >>> a = Vec(1, 2, 3) >>> b = Vec(3, 2, 1) added >>> a + b Vec(4, 4, 4) subtracted >>> a - b Vec(-2, 0, 2) and multiplied by a scalar on the left >>> 3.0 * a Vec(3.0, 6.0, 9.0) or on the right >>> a * 3.0 Vec(3.0, 6.0, 9.0) cGst||_dS(N(tlisttv(tselfR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__init__scCs.t|tstn|}||_|S(N(t isinstanceRt TypeErrorR(tclsRtinst((s(/usr/lib64/python2.7/Demo/classes/Vec.pytfromlists    cCs)djd|jD}dj|S(Ns, css|]}t|VqdS(N(trepr(t.0tx((s(/usr/lib64/python2.7/Demo/classes/Vec.pys %ssVec({0})(tjoinRtformat(Rtargs((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__repr__$scCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__len__(scCs |j|S(N(R(Rti((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt __getitem__+scCs?gt|j|jD]\}}||^q}tj|S(N(tzipRRR (RtotherR tyR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__add__.s2cCs?gt|j|jD]\}}||^q}tj|S(N(RRRR (RRR RR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__sub__3s2cCs-g|jD]}||^q }tj|S(N(RRR (RtscalarR R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__mul__8s ( t__name__t __module__t__doc__Rt classmethodR RRRRRRt__rmul__(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyRs       cCsddl}|jdS(Ni(tdoctestttestmod(R!((s(/usr/lib64/python2.7/Demo/classes/Vec.pyttest@s N((RR#(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyts? PK1]j%&&Dbm.pynu[# A wrapper around the (optional) built-in class dbm, supporting keys # and values of almost any type instead of just string. # (Actually, this works only for keys and values that can be read back # correctly after being converted to a string.) class Dbm: def __init__(self, filename, mode, perm): import dbm self.db = dbm.open(filename, mode, perm) def __repr__(self): s = '' for key in self.keys(): t = repr(key) + ': ' + repr(self[key]) if s: t = ', ' + t s = s + t return '{' + s + '}' def __len__(self): return len(self.db) def __getitem__(self, key): return eval(self.db[repr(key)]) def __setitem__(self, key, value): self.db[repr(key)] = repr(value) def __delitem__(self, key): del self.db[repr(key)] def keys(self): res = [] for key in self.db.keys(): res.append(eval(key)) return res def has_key(self, key): return self.db.has_key(repr(key)) def test(): d = Dbm('@dbm', 'rw', 0600) print d while 1: try: key = input('key: ') if d.has_key(key): value = d[key] print 'currently:', value value = input('value: ') if value is None: del d[key] else: d[key] = value except KeyboardInterrupt: print '' print d except EOFError: print '[eof]' break print d test() PK 3]e8dd scrambler.phpnu[scramble_type = $type; $this->t_first_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $this->t_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; $this->r = md5(microtime(true)); // random seed $this->t_scramble = array(); $this->silent = $conf->silent; if (isset($conf->scramble_mode)) { switch($conf->scramble_mode) { case 'numeric': $this->scramble_length_max = 32; $this->scramble_mode = $conf->scramble_mode; $this->t_first_chars = 'O'; $this->t_chars = '0123456789'; break; case 'hexa': $this->scramble_length_max = 32; $this->scramble_mode = $conf->scramble_mode; $this->t_first_chars = 'abcdefABCDEF'; break; case 'identifier': default: $this->scramble_length_max = 16; $this->scramble_mode = 'identifier'; } } $this->l1 = strlen($this->t_first_chars)-1; $this->l2 = strlen($this->t_chars )-1; $this->scramble_length_min = 2; $this->scramble_length = 5; if (isset($conf->scramble_length)) { $conf->scramble_length += 0; if ( ($conf->scramble_length >= $this->scramble_length_min) && ($conf->scramble_length <= $this->scramble_length_max) ) { $this->scramble_length = $conf->scramble_length; } } switch($type) { case 'constant': $this->case_sensitive = true; $this->t_ignore = array_flip($this->t_reserved_function_names); $this->t_ignore = array_merge($this->t_ignore,get_defined_constants(false)); if (isset($conf->t_ignore_constants)) { $t = $conf->t_ignore_constants; $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_constants_prefix)) { $t = $conf->t_ignore_constants_prefix; $t = array_flip($t); $this->t_ignore_prefix = $t; } break; case 'class_constant': $this->case_sensitive = true; $this->t_ignore = array_flip($this->t_reserved_function_names); $this->t_ignore = array_merge($this->t_ignore,get_defined_constants(false)); if ($conf->t_ignore_pre_defined_classes!='none') { if ($conf->t_ignore_pre_defined_classes=='all') $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_constants); if (is_array($conf->t_ignore_pre_defined_classes)) { $t_class_names = array_map('strtolower',$conf->t_ignore_pre_defined_classes); foreach($t_class_names as $class_name) if (isset($t_pre_defined_class_constants_by_class[$class_name])) $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_constants_by_class[$class_name]); } } if (isset($conf->t_ignore_class_constants)) { $t = $conf->t_ignore_class_constants; $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_class_constants_prefix)) { $t = $conf->t_ignore_class_constants_prefix; $t = array_flip($t); $this->t_ignore_prefix = $t; } break; case 'variable': $this->case_sensitive = true; $this->t_ignore = array_flip($this->t_reserved_variable_names); if (isset($conf->t_ignore_variables)) { $t = $conf->t_ignore_variables; $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_variables_prefix)) { $t = $conf->t_ignore_variables_prefix; $t = array_flip($t); $this->t_ignore_prefix = $t; } break; /* case 'function': $this->case_sensitive = false; $this->t_ignore = array_flip($this->t_reserved_function_names); $t = get_defined_functions(); $t = array_map('strtolower',$t['internal']); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); if (isset($conf->t_ignore_functions)) { $t = $conf->t_ignore_functions; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_functions_prefix)) { $t = $conf->t_ignore_functions_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = $t; } break; */ case 'property': $this->case_sensitive = true; $this->t_ignore = array_flip($this->t_reserved_variable_names); if ($conf->t_ignore_pre_defined_classes!='none') { if ($conf->t_ignore_pre_defined_classes=='all') $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_properties); if (is_array($conf->t_ignore_pre_defined_classes)) { $t_class_names = array_map('strtolower',$conf->t_ignore_pre_defined_classes); foreach($t_class_names as $class_name) if (isset($t_pre_defined_class_properties_by_class[$class_name])) $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_properties_by_class[$class_name]); } } if (isset($conf->t_ignore_properties)) { $t = $conf->t_ignore_properties; $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_properties_prefix)) { $t = $conf->t_ignore_properties_prefix; $t = array_flip($t); $this->t_ignore_prefix = $t; } break; case 'function_or_class': // same instance is used for scrambling classes, interfaces, and traits. and namespaces... and functions ...for aliasing $this->case_sensitive = false; $this->t_ignore = array_flip($this->t_reserved_function_names); $t = get_defined_functions(); $t = array_map('strtolower',$t['internal']); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); if (isset($conf->t_ignore_functions)) { $t = $conf->t_ignore_functions; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_functions_prefix)) { $t = $conf->t_ignore_functions_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = $t; } $this->t_ignore = array_merge($this->t_ignore, array_flip($this->t_reserved_class_names)); $this->t_ignore = array_merge($this->t_ignore, array_flip($this->t_reserved_variable_names)); // $this->t_ignore = array_merge($this->t_ignore, array_flip($this->t_reserved_function_names)); $t = get_defined_functions(); $t = array_flip($t['internal']); $this->t_ignore = array_merge($this->t_ignore,$t); if ($conf->t_ignore_pre_defined_classes!='none') { if ($conf->t_ignore_pre_defined_classes=='all') $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_classes); if (is_array($conf->t_ignore_pre_defined_classes)) { $t_class_names = array_map('strtolower',$conf->t_ignore_pre_defined_classes); foreach($t_class_names as $class_name) if (isset($t_pre_defined_classes[$class_name])) $this->t_ignore[$class_name] = 1; } } if (isset($conf->t_ignore_classes)) { $t = $conf->t_ignore_classes; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_interfaces)) { $t = $conf->t_ignore_interfaces; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_traits)) { $t = $conf->t_ignore_traits; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_namespaces)) { $t = $conf->t_ignore_namespaces; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_classes_prefix)) { $t = $conf->t_ignore_classes_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = array_merge($this->t_ignore_prefix,$t); } if (isset($conf->t_ignore_interfaces_prefix)) { $t = $conf->t_ignore_interfaces_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = array_merge($this->t_ignore_prefix,$t); } if (isset($conf->t_ignore_traits_prefix)) { $t = $conf->t_ignore_traits_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = array_merge($this->t_ignore_prefix,$t); } if (isset($conf->t_ignore_namespaces_prefix)) { $t = $conf->t_ignore_namespaces_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = array_merge($this->t_ignore_prefix,$t); } break; case 'method': $this->case_sensitive = false; if ($conf->parser_mode=='ONLY_PHP7') $this->t_ignore = array(); // in php7 method names can be keywords else $this->t_ignore = array_flip($this->t_reserved_function_names); $t = array_flip($this->t_reserved_method_names); $this->t_ignore = array_merge($this->t_ignore,$t); $t = get_defined_functions(); $t = array_map('strtolower',$t['internal']); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); if ($conf->t_ignore_pre_defined_classes!='none') { if ($conf->t_ignore_pre_defined_classes=='all') $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_methods); if (is_array($conf->t_ignore_pre_defined_classes)) { $t_class_names = array_map('strtolower',$conf->t_ignore_pre_defined_classes); foreach($t_class_names as $class_name) if (isset($t_pre_defined_class_methods_by_class[$class_name])) $this->t_ignore = array_merge($this->t_ignore,$t_pre_defined_class_methods_by_class[$class_name]); } } if (isset($conf->t_ignore_methods)) { $t = $conf->t_ignore_methods; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_methods_prefix)) { $t = $conf->t_ignore_methods_prefix; $t = array_map('strtolower',$t); $t = array_flip($t); $this->t_ignore_prefix = $t; } break; case 'label': $this->case_sensitive = true; $this->t_ignore = array_flip($this->t_reserved_function_names); if (isset($conf->t_ignore_labels)) { $t = $conf->t_ignore_labels; $t = array_flip($t); $this->t_ignore = array_merge($this->t_ignore,$t); } if (isset($conf->t_ignore_labels_prefix)) { $t = $conf->t_ignore_labels_prefix; $t = array_flip($t); $this->t_ignore_prefix = $t; } break; } if (isset($target_directory)) // the constructor will restore previous saved context if exists { $this->context_directory = $target_directory; if (file_exists("{$this->context_directory}/yakpro-po/context/{$this->scramble_type}")) { $t = unserialize(file_get_contents("{$this->context_directory}/yakpro-po/context/{$this->scramble_type}")); if ($t[0] !== self::SCRAMBLER_CONTEXT_VERSION) { fprintf(STDERR,"Error:\tContext format has changed! run with --clean option!".PHP_EOL); $this->context_directory = null; // do not overwrite incoherent values when exiting exit(1); } $this->t_scramble = $t[1]; $this->t_rscramble = $t[2]; $this->scramble_length = $t[3]; $this->label_counter = $t[4]; } } } function __destruct() { //print_r($this->t_scramble); if (!$this->silent) fprintf(STDERR,"Info:\t[%-17s] scrambled \t: %8d%s",$this->scramble_type,count($this->t_scramble),PHP_EOL); if (isset($this->context_directory)) // the destructor will save the current context { $t = array(); $t[0] = self::SCRAMBLER_CONTEXT_VERSION; $t[1] = $this->t_scramble; $t[2] = $this->t_rscramble; $t[3] = $this->scramble_length; $t[4] = $this->label_counter; file_put_contents("{$this->context_directory}/yakpro-po/context/{$this->scramble_type}",serialize($t)); } } private function str_scramble($s) // scramble the string according parameters { $c1 = $this->t_first_chars[mt_rand(0, $this->l1)]; // first char of the identifier $c2 = $this->t_chars [mt_rand(0, $this->l2)]; // prepending salt for md5 $this->r = str_shuffle(md5($c2.$s.md5($this->r))); // 32 chars random hex number derived from $s and lot of pepper and salt $s = $c1; switch($this->scramble_mode) { case 'numeric': for($i=0,$l=$this->scramble_length-1;$i<$l;++$i) $s .= $this->t_chars[base_convert(substr($this->r,$i,2),16,10)%($this->l2+1)]; break; case 'hexa': for($i=0,$l=$this->scramble_length-1;$i<$l;++$i) $s .= substr($this->r,$i,1); break; case 'identifier': default: for($i=0,$l=$this->scramble_length-1;$i<$l;++$i) $s .= $this->t_chars[base_convert(substr($this->r,2*$i,2),16,10)%($this->l2+1)]; } return $s; } private function case_shuffle($s) // this function is used to even more obfuscate insensitive names: on each acces to the name, a different randomized case of each letter is used. { for($i=0;$icase_sensitive ? $s : strtolower($s); if ( array_key_exists($r,$this->t_ignore) ) return $s; if (isset($this->t_ignore_prefix)) { foreach($this->t_ignore_prefix as $key => $dummy) if (substr($r,0,strlen($key))===$key) return $s; } if (!isset($this->t_scramble[$r])) // if not already scrambled: { for($i=0;$i<50;++$i) // try at max 50 times if the random generated scrambled string has already beeen generated! { $x = $this->str_scramble($s); $z = strtolower($x); $y = $this->case_sensitive ? $x : $z; if (isset($this->t_rscramble[$y]) || isset($this->t_ignore[$z]) ) // this random value is either already used or a reserved name { if (($i==5) && ($this->scramble_length < $this->scramble_length_max)) ++$this->scramble_length; // if not found after 5 attempts, increase the length... continue; // the next attempt will always be successfull, unless we already are maxlength } $this->t_scramble [$r] = $y; $this->t_rscramble[$y] = $r; break; } if (!isset($this->t_scramble[$r])) { fprintf(STDERR,"Scramble Error: Identifier not found after 50 iterations!%sAborting...%s",PHP_EOL,PHP_EOL); // should statistically never occur! exit(2); } } return $this->case_sensitive ? $this->t_scramble[$r] : $this->case_shuffle($this->t_scramble[$r]); } public function unscramble($s) { if (!$this->case_sensitive) $s = strtolower($s); return isset($this->t_rscramble[$s]) ? $this->t_rscramble[$s] : ''; } public function generate_label_name($prefix = "!label") { return $prefix.($this->label_counter++); } } ?> PK 3]*.ֲ'' config.phpnu[ 1 100/ratio is the percentage of chunks in a statements sequence ratio = 2 means 50% ratio = 100 mins 1% ... // if you increase the number of chunks, you increase also the obfuscation level ... and you increase also the performance overhead! public $strip_indentation = true; // all your obfuscated code will be generated on a single line public $abort_on_error = true; // self explanatory public $confirm = true; // rfu : will answer Y on confirmation request (reserved for future use ... or not...) public $silent = false; // display or not Information level messages. public $t_keep = false; // array of directory or file pathnames to keep 'as is' ... i.e. not obfuscate. public $t_skip = false; // array of directory or file pathnames to skip when exploring source tree structure ... they will not be on target! public $allow_and_overwrite_empty_files = false; // allow empty files to be kept as is public $source_directory = null; // self explanatory public $target_directory = null; // self explanatory public $max_nested_directory = 99; public $follow_symlinks = false; // WARNING: setting it to true will copy the directory instead of replicating the link... // WARNING: if there is a loop of links, $conf->max_nested_directory can be created... public $user_comment = null; // user comment to insert inside each obfuscated file public $extract_comment_from_line = null; // when both 2 are set, each obfuscated file will contain an extract of the corresponding source file, public $extract_comment_to_line = null; // starting from extract_comment_from_line number, and endng at extract_comment_to_line line number. private $comment = ''; function __construct() { $this->comment .= "/* __________________________________________________".PHP_EOL; $this->comment .= " | Obfuscated by YAK Pro - Php Obfuscator %-6.6s |".PHP_EOL; $this->comment .= " | on %s |".PHP_EOL; $this->comment .= " | GitHub: https://github.com/pk-fr/yakpro-po |".PHP_EOL; $this->comment .= " |__________________________________________________|".PHP_EOL; $this->comment .= "*/".PHP_EOL; } public function get_comment() { global $yakpro_po_version; $now = date('Y-m-d H:i:s'); return sprintf($this->comment,$yakpro_po_version,$now); } public function validate() { $this->shuffle_stmts_min_chunk_size += 0; if ($this->shuffle_stmts_min_chunk_size<1) $this->shuffle_stmts_min_chunk_size = 1; $this->shuffle_stmts_chunk_ratio += 0; if ($this->shuffle_stmts_chunk_ratio<2) $this->shuffle_stmts_chunk_ratio = 2; if ($this->shuffle_stmts_chunk_mode!='ratio') $this->shuffle_stmts_chunk_mode = 'fixed'; if (!isset( $this->t_ignore_pre_defined_classes)) $this->t_ignore_pre_defined_classes = 'all'; if (!is_array($this->t_ignore_pre_defined_classes) && ( $this->t_ignore_pre_defined_classes != 'none')) $this->t_ignore_pre_defined_classes = 'all'; } } ?> PK 3]ǝ#parser_extensions/my_autoloader.phpnu[obfuscate_string($node->value); if (!strlen($result)) return "''"; return '"'.$this->obfuscate_string($node->value).'"'; } //TODO: pseudo-obfuscate HEREDOC string protected function pScalar_InterpolatedString(PhpParser\Node\Scalar\InterpolatedString $node): string { /* if ($node->getAttribute('kind') === Scalar\String_::KIND_HEREDOC) { $label = $node->getAttribute('docLabel'); if ($label && !$this->encapsedContainsEndLabel($node->parts, $label)) { $nl = $this->phpVersion->supportsFlexibleHeredoc() ? $this->nl : $this->newline; if (count($node->parts) === 1 && $node->parts[0] instanceof Node\InterpolatedStringPart && $node->parts[0]->value === '' ) { return "<<<$label$nl$label{$this->docStringEndToken}"; } return "<<<$label$nl" . $this->pEncapsList($node->parts, null) . "$nl$label{$this->docStringEndToken}"; } } return '"' . $this->pEncapsList($node->parts, '"') . '"'; */ $result = ''; foreach ($node->parts as $element) { if ($element instanceof PhpParser\Node\InterpolatedStringPart) { $result .= $this->obfuscate_string($element->value); } else { $result .= '{' . $this->p($element) . '}'; } } return '"'.$result.'"'; } } ?> PK 3]iH櫬%parser_extensions/my_node_visitor.phpnu[shuffle_stmts) { if (isset($node->stmts)) { $stmts = $node->stmts; $chunk_size = shuffle_get_chunk_size($stmts); if ($chunk_size<=0) return false; // should never occur! if (count($stmts)>(2*$chunk_size)) { // $last_inst = array_pop($stmts); $stmts = shuffle_statements($stmts); // $stmts[] = $last_inst; $node->stmts = $stmts; return true; } } } return false; } private function get_identifier_name(PhpParser\Node $node) { if ($node instanceof PhpParser\Node\Identifier || $node instanceof PhpParser\Node\VarLikeIdentifier) return $node->name; return ''; } private function set_identifier_name(PhpParser\Node &$node,$name) { if ($node instanceof PhpParser\Node\Identifier || $node instanceof PhpParser\Node\VarLikeIdentifier) { $node->name = $name; } } private function get_node_name(PhpParser\Node $node) { if ($node->name instanceof PhpParser\Node\Name) { $parts = explode('\\',$node->name); $name = $parts[count($parts)-1]; return $name; } return false; } private function scramble_name(&$scrambler, &$node) // only last part { if ($node instanceof PhpParser\Node\Name || $node->name instanceof PhpParser\Node\Name) { if ($node instanceof PhpParser\Node\Name) $tmp_node = $node; if ($node->name instanceof PhpParser\Node\Name) $tmp_node = $node->name; $parts = explode('\\',$tmp_node->name); $name = $parts[count($parts)-1]; if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $parts[count($parts)-1] = $r; $tmp_node->name = implode('\\', $parts); return true; } } } return false; } private function scramble_names(&$scrambler, &$node) // all except last part { if ($node instanceof PhpParser\Node\Name || $node->name instanceof PhpParser\Node\Name) { if ($node instanceof PhpParser\Node\Name) $tmp_node = $node; if ($node->name instanceof PhpParser\Node\Name) $tmp_node = $node->name; $node_modified = false; $parts = explode('\\',$tmp_node->name); for($i=0;$iscramble($name); if ($r!==$name) { $parts[$i] = $r; $node_modified = true; } } } if ($node_modified) { $tmp_node->name = implode('\\', $parts); return true; } } return false; } private function scramble_all_names(&$scrambler, &$node) // all pparts { if ($node instanceof PhpParser\Node\Name || $node->name instanceof PhpParser\Node\Name) { if ($node instanceof PhpParser\Node\Name) $tmp_node = $node; if ($node->name instanceof PhpParser\Node\Name) $tmp_node = $node->name; $node_modified = false; $parts = explode('\\',$tmp_node->name); for($i=0;$iscramble($name); if ($r!==$name) { $parts[$i] = $r; $node_modified = true; } } } if ($node_modified) { $tmp_node->name = implode('\\', $parts); return true; } } return false; } public function enterNode(PhpParser\Node $node) { global $conf; global $t_scrambler; if (count($this->t_node_stack)) { $node->setAttribute('parent', $this->t_node_stack[count($this->t_node_stack)-1]); } $this->t_node_stack[] = $node; if ($conf->obfuscate_loop_statement) // loop statements are replaced by goto ... { $scrambler = $t_scrambler['label']; if ( ($node instanceof PhpParser\Node\Stmt\For_) || ($node instanceof PhpParser\Node\Stmt\Foreach_) || ($node instanceof PhpParser\Node\Stmt\Switch_) || ($node instanceof PhpParser\Node\Stmt\While_) || ($node instanceof PhpParser\Node\Stmt\Do_) ) { $label_loop_break_name = $scrambler->scramble($scrambler->generate_label_name()); $label_loop_continue_name = $scrambler->scramble($scrambler->generate_label_name()); $this->t_loop_stack[] = array($label_loop_break_name,$label_loop_continue_name); } } if ( ($node instanceof PhpParser\Node\Stmt\Class_) && ($node->name != null) ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $this->current_class_name = $name; } } if ($node instanceof PhpParser\Node\Stmt\ClassConst) { $this->is_in_class_const_definition = true; } } public function leaveNode(PhpParser\Node $node) { global $conf; global $t_scrambler; global $debug_mode; $node_modified = false; if ($node instanceof PhpParser\Node\Stmt\Class_) $this->current_class_name = null; if ($node instanceof PhpParser\Node\Stmt\ClassConst) $this->is_in_class_const_definition = false; if ($conf->obfuscate_string_literal) { if ($node instanceof PhpParser\Node\Stmt\InlineHTML) { $node = new PhpParser\Node\Stmt\Echo_([new PhpParser\Node\Scalar\String_($node->value)]); $node_modified = true; } } if ($conf->obfuscate_variable_name) { $scrambler = $t_scrambler['variable']; if ($node instanceof PhpParser\Node\Expr\Variable) { $name = $node->name; if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $node->name = $r; $node_modified = true; } } } if ( ($node instanceof PhpParser\Node\Stmt\Catch_) || ($node instanceof PhpParser\Node\ClosureUse) || ($node instanceof PhpParser\Node\Param) ) { $name = $node->{'var'}; // equivalent to $node->var, that works also on my php version! if ( is_string($name) && (strlen($name) !== 0) ) // but 'var' is a reserved function name, so there is no warranty { // that it will work in the future, so the $node->{'var'} form $r = $scrambler->scramble($name); // has been used! if ($r!==$name) { $node->{'var'} = $r; $node_modified = true; } } } } if ($conf->obfuscate_function_name) { $scrambler = $t_scrambler['function_or_class']; if ($node instanceof PhpParser\Node\Stmt\Function_) { $name = $node->name->name; if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $node->name->name = $r; $node_modified = true; } } } if ($node instanceof PhpParser\Node\Expr\FuncCall ) { // $node->name->parts was not set (prev version) when indirect call (i.e.function name is a variable value!) if ($this->scramble_name($scrambler, $node)) $node_modified = true; if ($this->get_node_name($node) == 'function_exists') { for($ok=false;;) { if (!isset($node->args[0]->value)) break; if (count($node->args)!=1) break; $arg = $node->args[0]->value; if (! ($arg instanceof PhpParser\Node\Scalar\String_) ) { $ok = true; $warning = true; break; } $name = $arg->value; if (! is_string($name) || (strlen($name) == 0) ) break; $ok = true; $warning= false; $r = $scrambler->scramble($name); if ($r!==$name) { $arg->value = $r; $node_modified = true; } break; } if (!$ok) { throw new Exception("Error: your use of function_exists() function is not compatible with yakpro-po!".PHP_EOL."\tOnly 1 literal string parameter is allowed..."); } if ($warning) fprintf(STDERR, "Warning: your use of function_exists() function is not compatible with yakpro-po!".PHP_EOL."\t Only 1 literal string parameter is allowed...".PHP_EOL); } } } if ($conf->obfuscate_class_name) { $scrambler = $t_scrambler['function_or_class']; if ($node instanceof PhpParser\Node\Stmt\Class_) { if ($node->name != null) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } if (isset($node->{'extends'})) { if ($this->scramble_name($scrambler, $node->{'extends'})) $node_modified = true; } } if ( ($node instanceof PhpParser\Node\Expr\New_) || ($node instanceof PhpParser\Node\Expr\StaticCall) || ($node instanceof PhpParser\Node\Expr\StaticPropertyFetch) || ($node instanceof PhpParser\Node\Expr\ClassConstFetch) || ($node instanceof PhpParser\Node\Expr\Instanceof_) ) { if (isset($node->{'class'})) { if ($this->scramble_name($scrambler, $node->{'class'})) $node_modified = true; } } if ($node instanceof PhpParser\Node\Param) { if (isset($node->type)) { if ($this->scramble_name($scrambler, $node->type)) $node_modified = true; } } if ($node instanceof PhpParser\Node\Stmt\ClassMethod || $node instanceof PhpParser\Node\Stmt\Function_) { if (isset($node->returnType)) { $node_tmp = $node->returnType; if ($node_tmp instanceof PhpParser\Node\NullableType && isset($node_tmp->type) ) { $node_tmp = $node_tmp->type; } if ($node_tmp instanceof PhpParser\Node\Name) { if ($this->scramble_name($scrambler, $node_tmp)) $node_modified = true; } } } if ($node instanceof PhpParser\Node\Stmt\Catch_) { if (isset($node->types)) { $types = $node->types; foreach($types as &$type) { if ($this->scramble_name($scrambler, $type)) $node_modified = true; } } } } if ($conf->obfuscate_interface_name) { $scrambler = $t_scrambler['function_or_class']; if ($node instanceof PhpParser\Node\Stmt\Interface_) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } if ( isset($node->{'extends'}) && count($node->{'extends'}) ) { for($j=0;$j{'extends'});++$j) { if ($this->scramble_name($scrambler, $node->{'extends'}[$j])) $node_modified = true; } } } if ($node instanceof PhpParser\Node\Stmt\Class_) { if ( isset($node->{'implements'}) && count($node->{'implements'}) ) { for($j=0;$j{'implements'});++$j) { if ($this->scramble_name($scrambler, $node->{'implements'}[$j])) $node_modified = true; } } } } if ($conf->obfuscate_trait_name) { $scrambler = $t_scrambler['function_or_class']; if ($node instanceof PhpParser\Node\Stmt\Trait_) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } if ($node instanceof PhpParser\Node\Stmt\TraitUse) { if ( isset($node->{'traits'}) && count($node->{'traits'}) ) { for($j=0;$j{'traits'});++$j) { if ($this->scramble_name($scrambler, $node->{'traits'}[$j])) $node_modified = true; } } } } if ($conf->obfuscate_property_name) { $scrambler = $t_scrambler['property']; if ( ($node instanceof PhpParser\Node\Expr\PropertyFetch) || ($node instanceof PhpParser\Node\PropertyItem) || ($node instanceof PhpParser\Node\Expr\StaticPropertyFetch) ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } } if ($conf->obfuscate_method_name) { $scrambler = $t_scrambler['method']; if ( ($node instanceof PhpParser\Node\Stmt\ClassMethod) || ($node instanceof PhpParser\Node\Expr\MethodCall) || ($node instanceof PhpParser\Node\Expr\StaticCall) ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } } if ($conf->obfuscate_constant_name) { $scrambler = $t_scrambler['constant']; if ($node instanceof PhpParser\Node\Expr\FuncCall) // processing define('constant_name',value); { if (isset($node->name) && ($node->name instanceof PhpParser\Node\Name)) // not set when indirect call (i.e.function name is a variable value!) { $parts = explode('\\',$node->name); $fn_name = $parts[count($parts)-1]; if ( is_string($fn_name) && ( ($fn_name=='define') || ($fn_name=='defined') ) ) { for($ok=false;;) { if (!isset($node->args[0]->value)) break; if ( ($fn_name=='define') && (count($node->args)!=2) ) break; $arg = $node->args[0]->value; if (! ($arg instanceof PhpParser\Node\Scalar\String_) ) break; $name = $arg->value; if (! is_string($name) || (strlen($name) == 0) ) break; $ok = true; $r = $scrambler->scramble($name); if ($r!==$name) { $arg->value = $r; $node_modified = true; } break; } if (!$ok) { if ($fn_name=='define') throw new Exception("Error: your use of $fn_name() function is not compatible with yakpro-po!".PHP_EOL."\tOnly 2 parameters, when first is a literal string is allowed..."); else throw new Exception("Error: your use of $fn_name() function is not compatible with yakpro-po!".PHP_EOL."\tOnly 1 literal string parameter is allowed..."); } } } } if ($node instanceof PhpParser\Node\Expr\ConstFetch) { if ($this->scramble_name($scrambler, $node)) $node_modified = true; } if ( ($node instanceof PhpParser\Node\Const_) && !$this->is_in_class_const_definition ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } } if ($conf->obfuscate_class_constant_name) { $scrambler = $t_scrambler['class_constant']; if ( ($node instanceof PhpParser\Node\Const_) && $this->is_in_class_const_definition ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } if ($node instanceof PhpParser\Node\Expr\ClassConstFetch) { $name = $node->name; $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $this->set_identifier_name($node->name,$r); $node_modified = true; } } } } if ($node instanceof PhpParser\Node\UseItem) { if ($conf->obfuscate_function_name || $conf->obfuscate_class_name) { if (isset($node->alias)) { if (!$conf->obfuscate_function_name || !$conf->obfuscate_class_name) { fprintf(STDERR, "Warning:[use alias] cannot determine at compile time if it is a function or a class alias".PHP_EOL."\tyou must obfuscate both functions and classes or none...".PHP_EOL."\tObfuscated code may not work!".PHP_EOL); } $scrambler = $t_scrambler['function_or_class']; $name = $this->get_identifier_name($node->alias); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { //$node->alias = $r; $this->set_identifier_name($node->alias,$r); $node_modified = true; } } } } } if ($conf->obfuscate_namespace_name) { $scrambler = $t_scrambler['function_or_class']; if ( ($node instanceof PhpParser\Node\Stmt\Namespace_) || ($node instanceof PhpParser\Node\UseItem) ) { if ($this->scramble_all_names($scrambler, $node)) $node_modified = true; } if ( ($node instanceof PhpParser\Node\Expr\FuncCall) || ($node instanceof PhpParser\Node\Expr\ConstFetch) ) { if ($this->scramble_names($scrambler, $node)) $node_modified = true; } if ( ($node instanceof PhpParser\Node\Expr\New_) || ($node instanceof PhpParser\Node\Expr\Instanceof_) || ($node instanceof PhpParser\Node\Expr\StaticCall) || ($node instanceof PhpParser\Node\Expr\StaticPropertyFetch) || ($node instanceof PhpParser\Node\Expr\ClassConstFetch) ) { if (isset($node->{'class'})) // parts was not set in prev version when indirect call (i.e.function name is a variable value!) { if ($this->scramble_names($scrambler, $node->{'class'})) $node_modified = true; } } if ($node instanceof PhpParser\Node\Stmt\Class_) { if (isset($node->{'extends'})) { if ($this->scramble_names($scrambler, $node->{'extends'})) $node_modified = true; } if ( isset($node->{'implements'}) && count($node->{'implements'}) ) { for($j=0;$j{'implements'});++$j) { if ($this->scramble_names($scrambler, $node->{'implements'}[$j])) $node_modified = true; } } } if ($node instanceof PhpParser\Node\Param) { if (isset($node->type)) { if ($this->scramble_names($scrambler, $node->type)) $node_modified = true; } } if ($node instanceof PhpParser\Node\Stmt\Interface_) { if (isset($node->{'extends'})) { for($j=0;$j{'extends'});++$j) { if ($this->scramble_names($scrambler, $node->{'extends'}[$j])) $node_modified = true; } } } if ($node instanceof PhpParser\Node\Stmt\TraitUse) { if ( isset($node->{'traits'}) && count($node->{'traits'}) ) { for($j=0;$j{'traits'});++$j) { if ($this->scramble_names($scrambler, $node->{'traits'}[$j])) $node_modified = true; } } } if ($node instanceof PhpParser\Node\Stmt\Catch_) { if (isset($node->types)) { $types = $node->types; foreach($types as &$type) { if ($this->scramble_names($scrambler, $type)) $node_modified = true; } } } } if ($conf->obfuscate_label_name) // label: goto label; - { $scrambler = $t_scrambler['label']; if ( ($node instanceof PhpParser\Node\Stmt\Label) || ($node instanceof PhpParser\Node\Stmt\Goto_) ) { $name = $this->get_identifier_name($node->name); if ( is_string($name) && (strlen($name) !== 0) ) { $r = $scrambler->scramble($name); if ($r!==$name) { $node->name->name = $r; $node_modified = true; } } } } if ($conf->obfuscate_if_statement) // if else elseif are replaced by goto ... { $scrambler = $t_scrambler['label']; $ok_to_scramble = false; if ( ($node instanceof PhpParser\Node\Stmt\If_) ) // except if function_exists is ther... { $ok_to_scramble = true; $condition = $node->cond; if ($condition instanceof PhpParser\Node\Expr\BooleanNot) { $expr = $condition->expr; if ($expr instanceof PhpParser\Node\Expr\FuncCall) { $name = $expr->name; if ($name instanceof PhpParser\Node\Name) { $parts = explode('\\',$name->name); $part = $parts[0]; if ($part == 'function_exists') { $ok_to_scramble = false; } } } } } if ( $ok_to_scramble ) { $condition = $node->cond; $stmts = $node->stmts; $else = isset($node->{'else'}) ? $node->{'else'}->stmts : null; $elseif = $node->elseifs; if (isset($elseif) && count($elseif)) // elseif mode { $label_endif_name = $scrambler->scramble($scrambler->generate_label_name()); $label_endif = array(new PhpParser\Node\Stmt\Label($label_endif_name)); $goto_endif = array(new PhpParser\Node\Stmt\Goto_($label_endif_name)); $new_nodes_1 = array(); $new_nodes_2 = array(); $label_if_name = $scrambler->scramble($scrambler->generate_label_name()); $label_if = array(new PhpParser\Node\Stmt\Label($label_if_name)); $goto_if = array(new PhpParser\Node\Stmt\Goto_($label_if_name)); $if = new PhpParser\Node\Stmt\If_($condition); $if->stmts = $goto_if; $new_nodes_1 = array_merge($new_nodes_1,array($if)); $new_nodes_2 = array_merge($new_nodes_2,$label_if,$stmts,$goto_endif); for($i=0;$icond; $stmts = $elseif[$i]->stmts; $label_if_name = $scrambler->scramble($scrambler->generate_label_name()); $label_if = array(new PhpParser\Node\Stmt\Label($label_if_name)); $goto_if = array(new PhpParser\Node\Stmt\Goto_($label_if_name)); $if = new PhpParser\Node\Stmt\If_($condition); $if->stmts = $goto_if; $new_nodes_1 = array_merge($new_nodes_1,array($if)); $new_nodes_2 = array_merge($new_nodes_2,$label_if,$stmts); if ($iscramble($scrambler->generate_label_name()); $label_then = array(new PhpParser\Node\Stmt\Label($label_then_name)); $goto_then = array(new PhpParser\Node\Stmt\Goto_($label_then_name)); $label_endif_name = $scrambler->scramble($scrambler->generate_label_name()); $label_endif = array(new PhpParser\Node\Stmt\Label($label_endif_name)); $goto_endif = array(new PhpParser\Node\Stmt\Goto_($label_endif_name)); $node->stmts = $goto_then; $node->{'else'} = null; return array_merge(array($node),$else,$goto_endif,$label_then,$stmts,$label_endif); } else // no else statement found { if ($condition instanceof PhpParser\Node\Expr\BooleanNot) // avoid !! in generated code { $new_condition = $condition->expr; } else { $new_condition = new PhpParser\Node\Expr\BooleanNot($condition); } $label_endif_name = $scrambler->scramble($scrambler->generate_label_name()); $label_endif = array(new PhpParser\Node\Stmt\Label($label_endif_name)); $goto_endif = array(new PhpParser\Node\Stmt\Goto_($label_endif_name)); $node->cond = $new_condition; $node->stmts = $goto_endif; return array_merge(array($node),$stmts,$label_endif); } } } } if ($conf->obfuscate_loop_statement) // for while do while are replaced by goto ... { $scrambler = $t_scrambler['label']; if ($node instanceof PhpParser\Node\Stmt\For_) { list($label_loop_break_name,$label_loop_continue_name) = array_pop($this->t_loop_stack); //$init = $node->init; $init = null; if ((isset($node->init) && count($node->init))) foreach($node->init as $tmp) $init[] = new PhpParser\Node\Stmt\Expression($tmp); $condition = (isset($node->cond) && count($node->cond)) ? $node->cond[0] : null; //$loop = $node->loop; $loop = null; if ((isset($node->loop) && count($node->loop))) foreach($node->loop as $tmp) $loop[] = new PhpParser\Node\Stmt\Expression($tmp); $stmts = $node->stmts; $label_loop_name = $scrambler->scramble($scrambler->generate_label_name()); $label_loop = array(new PhpParser\Node\Stmt\Label($label_loop_name)); $goto_loop = array(new PhpParser\Node\Stmt\Goto_($label_loop_name)); $label_break = array(new PhpParser\Node\Stmt\Label($label_loop_break_name)); $goto_break = array(new PhpParser\Node\Stmt\Goto_($label_loop_break_name)); $label_continue = array(new PhpParser\Node\Stmt\Label($label_loop_continue_name)); $goto_continue = array(new PhpParser\Node\Stmt\Goto_($label_loop_continue_name)); $new_node = array(); if (isset($init)) { $new_node = array_merge($new_node,$init); } $new_node = array_merge($new_node,$label_loop); if (isset($condition)) { if ($condition instanceof PhpParser\Node\Expr\BooleanNot) // avoid !! in generated code { $new_condition = $condition->expr; } else { $new_condition = new PhpParser\Node\Expr\BooleanNot($condition); } $if = new PhpParser\Node\Stmt\If_($new_condition); $if->stmts = $goto_break; $new_node = array_merge($new_node,array($if)); } if (isset($stmts)) { $new_node = array_merge($new_node,$stmts); } $new_node = array_merge($new_node,$label_continue); if (isset($loop)) { $new_node = array_merge($new_node,$loop); } $new_node = array_merge($new_node,$goto_loop); $new_node = array_merge($new_node,$label_break); return $new_node; } if ( $node instanceof PhpParser\Node\Stmt\Foreach_) { list($label_loop_break_name,$label_loop_continue_name) = array_pop($this->t_loop_stack); $label_break = array(new PhpParser\Node\Stmt\Label($label_loop_break_name)); $node->stmts[] = new PhpParser\Node\Stmt\Label($label_loop_continue_name); $this->shuffle_stmts($node); return array_merge(array($node),$label_break); } if ( $node instanceof PhpParser\Node\Stmt\Switch_) { list($label_loop_break_name,$label_loop_continue_name) = array_pop($this->t_loop_stack); $label_break = array(new PhpParser\Node\Stmt\Label($label_loop_break_name)); $label_continue = array(new PhpParser\Node\Stmt\Label($label_loop_continue_name)); return array_merge(array($node),$label_continue,$label_break); } if ( $node instanceof PhpParser\Node\Stmt\While_) { list($label_loop_break_name,$label_loop_continue_name) = array_pop($this->t_loop_stack); $condition = $node->cond; $stmts = $node->stmts; $label_break = array(new PhpParser\Node\Stmt\Label($label_loop_break_name)); $goto_break = array(new PhpParser\Node\Stmt\Goto_($label_loop_break_name)); $label_continue = array(new PhpParser\Node\Stmt\Label($label_loop_continue_name)); $goto_continue = array(new PhpParser\Node\Stmt\Goto_($label_loop_continue_name)); if ($condition instanceof PhpParser\Node\Expr\BooleanNot) // avoid !! in generated code { $new_condition = $condition->expr; } else { $new_condition = new PhpParser\Node\Expr\BooleanNot($condition); } $if = new PhpParser\Node\Stmt\If_($new_condition); $if->stmts = $goto_break; return array_merge($label_continue,array($if),$stmts,$goto_continue,$label_break); } if ( $node instanceof PhpParser\Node\Stmt\Do_) { list($label_loop_break_name,$label_loop_continue_name) = array_pop($this->t_loop_stack); $condition = $node->cond; $stmts = $node->stmts; $label_break = array(new PhpParser\Node\Stmt\Label($label_loop_break_name)); $label_continue = array(new PhpParser\Node\Stmt\Label($label_loop_continue_name)); $goto_continue = array(new PhpParser\Node\Stmt\Goto_($label_loop_continue_name)); $if = new PhpParser\Node\Stmt\If_($condition); $if->stmts = $goto_continue; return array_merge($label_continue,$stmts,array($if),$label_break); } if ($node instanceof PhpParser\Node\Stmt\Break_) { $n = 1; if (isset($node->num)) { if ($node->num instanceof PhpParser\Node\Scalar\LNumber) { $n = $node->num->value; } else { throw new Exception("Error: your use of break statement is not compatible with yakpro-po!".PHP_EOL."\tAt max 1 literal numeric parameter is allowed..."); } } if (count($this->t_loop_stack) - $n <0) { throw new Exception("Error: break statement outside loop found!;".PHP_EOL.(($debug_mode==2) ? print_r($node,true) : '') ); } list($label_loop_break_name,$label_loop_continue_name) = $this->t_loop_stack[count($this->t_loop_stack) - $n ]; $node = new PhpParser\Node\Stmt\Goto_($label_loop_break_name); $node_modified = true; } if ($node instanceof PhpParser\Node\Stmt\Continue_) { $n = 1; if (isset($node->num)) { if ($node->num instanceof PhpParser\Node\Scalar\LNumber) { $n = $node->num->value; } else { throw new Exception("Error: your use of continue statement is not compatible with yakpro-po!".PHP_EOL."\tAt max 1 literal numeric parameter is allowed..."); } } if (count($this->t_loop_stack) - $n <0) { throw new Exception("Error: continue statement outside loop found!;".PHP_EOL.(($debug_mode==2) ? print_r($node,true) : '')); } list($label_loop_break_name,$label_loop_continue_name) = $this->t_loop_stack[count($this->t_loop_stack) - $n ]; $node = new PhpParser\Node\Stmt\Goto_($label_loop_continue_name); $node_modified = true; } } if ($conf->shuffle_stmts) { if ( ($node instanceof PhpParser\Node\Stmt\Function_) || ($node instanceof PhpParser\Node\Expr\Closure) || ($node instanceof PhpParser\Node\Stmt\ClassMethod) || ($node instanceof PhpParser\Node\Stmt\Foreach_) // occurs when $conf->obfuscate_loop_statement is set to false || ($node instanceof PhpParser\Node\Stmt\If_) // occurs when $conf->obfuscate_loop_statement is set to false || ($node instanceof PhpParser\Node\Stmt\TryCatch) || ($node instanceof PhpParser\Node\Stmt\Catch_) || ($node instanceof PhpParser\Node\Stmt\Case_) //|| ($node instanceof PhpParser\Node\Stmt\Namespace_) ) { if ($this->shuffle_stmts($node)) $node_modified = true; } if ( ($node instanceof PhpParser\Node\Stmt\If_) ) // occurs when $conf->obfuscate_if_statement is set to false { if (isset($node->{'else'})) { if ($this->shuffle_stmts($node->{'else'})) $node_modified = true; } $elseif = $node->elseifs; if (isset($elseif) && count($elseif)) // elseif mode { for($i=0;$ishuffle_stmts($elseif[$i])) $node_modified = true; } } } } array_pop($this->t_node_stack); if ($node_modified) return $node; } } ?> PK1] Dbm.pycnu[PK1]nL6 6  Range.pynu[PK1](( }bitvec.pynu[PK1]I?Rev.pynu[PK1]1 1 GRev.pyonu[PK1]E WSRange.pyonu[PK1]E cRange.pycnu[PK1]FI&'&' sComplex.pyonu[PK1](   READMEnu[PK1]ΎMM`Vec.pynu[PK1]w Dates.pyonu[PK1]cAC<5(5( ¿bitvec.pycnu[PK1]cAC<5(5( 1bitvec.pyonu[PK1]:6  Vec.pyonu[PK1]u+&& Complex.pynu[PK1]/ BDates.pynu[PK1]FI&'&' aComplex.pycnu[PK1] Dbm.pyonu[PK1]1 1 ,Rev.pycnu[PK1]w Dates.pycnu[PK1]:6  sVec.pycnu[PK1]j%&&Dbm.pynu[PK 3]e8dd  scrambler.phpnu[PK 3]*.ֲ'' 1config.phpnu[PK 3]ǝ#Yparser_extensions/my_autoloader.phpnu[PK 3]w '`parser_extensions/my_pretty_printer.phpnu[PK 3]iH櫬%jparser_extensions/my_node_visitor.phpnu[PK