Package pyffi :: Package spells :: Module check
[hide private]
[frames] | no frames]

Source Code for Module pyffi.spells.check

 1  """Module which contains all spells that check something in a file 
 2  (format-independently).""" 
 3   
 4  # -------------------------------------------------------------------------- 
 5  # ***** BEGIN LICENSE BLOCK ***** 
 6  # 
 7  # Copyright (c) 2007-2011, Python File Format Interface 
 8  # All rights reserved. 
 9  # 
10  # Redistribution and use in source and binary forms, with or without 
11  # modification, are permitted provided that the following conditions 
12  # are met: 
13  # 
14  #    * Redistributions of source code must retain the above copyright 
15  #      notice, this list of conditions and the following disclaimer. 
16  # 
17  #    * Redistributions in binary form must reproduce the above 
18  #      copyright notice, this list of conditions and the following 
19  #      disclaimer in the documentation and/or other materials provided 
20  #      with the distribution. 
21  # 
22  #    * Neither the name of the Python File Format Interface 
23  #      project nor the names of its contributors may be used to endorse 
24  #      or promote products derived from this software without specific 
25  #      prior written permission. 
26  # 
27  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
28  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
29  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
30  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
31  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
32  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
33  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
34  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
35  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
36  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
37  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
38  # POSSIBILITY OF SUCH DAMAGE. 
39  # 
40  # ***** END LICENSE BLOCK ***** 
41  # -------------------------------------------------------------------------- 
42   
43  from pyffi.spells import Spell 
44 45 -class SpellRead(Spell):
46 """A spell which does nothing, besides reading the file.""" 47 48 SPELLNAME = "check_read" 49 READONLY = True 50
51 - def dataentry(self):
52 # prevent recursing into the tree 53 return False
54
55 -class SpellReadWrite(SpellRead):
56 """A spell which writes the data to a temporary file (essentially, 57 it is like L{SpellRead} but it forces --dry-run and sets READONLY to 58 ``False``. 59 """ 60 61 SPELLNAME = "check_readwrite" 62 READONLY = False 63 changed = True # we want it to write the file back 64 65 @classmethod
66 - def toastentry(cls, toaster):
67 # force dry run 68 toaster.options["dryrun"] = True 69 # the spell always acts 70 return True
71