001:
002:
003:
004:
005:
006:
007:
008:
009: reloadables=[]
010:
011:
012:
013: import gtk,gobject
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025: datafile=None
026: dataname=None
027: from standing import boatinit as boatlist
028:
029:
030:
031: activecol=None
032: curpath=None
033: commentisopen=False
034:
035:
036:
037: class History(object):
038: def __init__(self):
039: self.committed=[]
040: self.cursor=0
041: self.tag=None
042: self.provisional=[]
043: def display(self):
044: for (undo,redo) in self.committed:
045: print " (%-37s, %-37s)"%(undo.__doc__,redo.__doc__)
046: def truncate(self,tag):
047: assert tag<>None
048: self.tag=tag
049: self.provisional=[]
050: def append(self,undo=(lambda *p,**pp: p),redo=(lambda *p,**pp: p)):
051: assert self.tag<>None
052: try:
053: self.provisional.append((undo,redo))
054: except KeyError:
055: raise TypeError
056: def transaction(self):
057: assert self.tag<>None
058: return self.tag
059: def transact(self,tag):
060: if self.tag==tag:
061: self.rollback()
062: else:
063: self.commit()
064: def commit(self):
065: assert self.tag<>None
066: self.committed[self.cursor:]=self.provisional
067: self.cursor=len(self.committed)
068: self.tag=None
069: self.provisional=[]
070: def rollback(self):
071: assert self.tag<>None
072: self.tag=None
073: self.provisional=[]
074: def undo(self,**pp):
075: assert self.tag==None and self.provisional==[]
076: context=()
077: while self.cursor>0:
078: self.cursor-=1
079: change=self.committed[self.cursor]
080: assert isinstance(change,tuple) and len(change)==2
081: context=change[0](*context,**pp)
082: if isinstance(context,dict): return context
083: if context==None: context=()
084: elif not isinstance(context,tuple): context=(context,)
085: else:
086: return {"context":context}
087: def redo(self,**pp):
088: assert self.tag==None and self.provisional==[]
089: context=()
090: maxcursor=len(self.committed)
091: while self.cursor<maxcursor:
092: change=self.committed[self.cursor]
093: assert isinstance(change,tuple) and len(change)==2
094: context=change[1](*context,**pp)
095: self.cursor+=1
096: if isinstance(context,dict): return context
097: if context==None: context=()
098: elif not isinstance(context,tuple): context=(context,)
099: else:
100: return {"context":context}
101: history=History()
102:
103:
104:
105: model=gtk.ListStore(int,int,str,str,str,str,gobject.TYPE_BOOLEAN,bool,bool,bool,bool,bool,str,str,str,str,str)
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
PyScore
A badly written regatta scoring programme in Python and PyGtk.
register
relational
standing
tabulate
timesheet
treemodel
utility
Copyright 2004, M.E.J.Draisey
This file is part of pyscore.
pyscore is free software; you can redistribute it and/or modify it under
the terms of the GNU General
Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
pyscore is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pyscore; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Formatted with
GNU source-highlight:
http:// www.gnu.org/ software/ src-highlite