~ubuntu-branches/ubuntu/karmic/gnome-games/karmic-proposed

« back to all changes in this revision

Viewing changes to gnome-sudoku/src/lib/saver.py

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2009-04-14 12:31:51 UTC
  • mfrom: (1.1.65)
  • Revision ID: package-import@ubuntu.com-20090414123151-v18w2slnw6nx1f4d
Tags: 1:2.26.1-0ubuntu1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
            except:
212
212
                print 'Warning: could not read file',f
213
213
            else:
214
 
                jar['saved_at']=os.stat(f)[8]
215
 
                games.append(jar)
 
214
                if self.is_valid(jar):
 
215
                    jar['saved_at']=os.stat(f)[8]
 
216
                    games.append(jar)
 
217
                else:
 
218
                    print 'Warning: malformed save game',f
216
219
        return games
217
 
        
 
220
 
 
221
    def is_valid (self, jar):
 
222
        virgin = jar['game'].split('\n')[0].replace(' ','')
 
223
        played = jar['game'].split('\n')[1].replace(' ','')
 
224
 
 
225
        if len(virgin) != 81 or len(played) != 81:
 
226
            return False
 
227
 
 
228
        if not virgin.isdigit() or not played.isdigit():
 
229
            return False
 
230
 
 
231
        return True
218
232