/usr/lib/python2.7/dist-packages/mx/Stack/UserStack.py is in python-egenix-mxstack 3.2.7-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | """ A pure Python Stack implementation modelled after mxStack.
Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2013, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further information on copyrights,
or contact the author. All Rights Reserved.
"""
class UserStack:
def __init__(self):
self.stack = ()
def push(self,x):
self.stack = (x,self.stack)
def pop(self):
x, self.stack = self.stack
return x
def not_empty(self):
return len(self.stack) != 0
def top(self):
return self.stack[0]
def __len__(self):
i = 0
s = self.stack
while len(s) != 0:
s = s[1]
i = i + 1
return i
def __repr__(self):
l = []
s = self.stack
while len(s) != 0:
l.append(repr(s[0]))
s = s[1]
return '<UserStack [%s]>' % ', '.join(l)
def __str__(self):
l = []
s = self.stack
while len(s) != 0:
l.append(s[0])
s = s[1]
return 's' + repr(l)
|