Exemplo n.º 1
0
   def __init__(self,name,outputfrom=None,directory=None,items=[],customblocks=[],standardblocks=[]):
      #outputfrom is a 'program' object, directory is a string
      SUSYFile.__init__(self,name,outputfrom,directory)
      self.customblocks = customblocks
      itemtype1 = Blueprint(Item," %(index)d %(value)e # %(name)ls")
      itemtype2 = Blueprint(Item," %(index)d %(value)d # %(name)ls")   #bjf> be careful, this may incorrectly assume some entries are supposed to be integers if they happen to be an integer in the template. Ensure zero entries have a decimal place, i.e. 0.0e0 or similar
      itemtype3 = Blueprint(Item," %(index)d %(value)s # %(name)ls")
      itemtype4 = Blueprint(Item," %(index)d %(value)ls")    #bjf> I added this because it wasn't reading in lines with no comment. Works for strings only atm. Added to "items" list as well. Example: Softsusy output, block SPINFO, index 4, value "Point invalid: [ MuSqWrongsign ]", no name (as you call it).
      itemtype5 = Blueprint(Item," %(value)e # %(name)ls")   #bjf> needed for 'alpha' block of softsusy output, has only one entry, which has no index
      itemtype6 = Blueprint(Item," %(value)e")   #bjf> as above, but accounting for possibility that there is no comment
      #bjf> want an item that extracts values from block itself. Try the following:
      #itemtype7 = Blueprint(Block,"BLOCK %(name)s Q= %(value)e # %(comment)ls")
      #itemtype8 = Blueprint(Block,"BLOCK %(name)s Q=%(value)e # %(comment)ls") 
      #itemtype9 = Blueprint(Block,"BLOCK %(name)s Q= %(value)e")
      #<bjf
      blankitem = Blueprint(Item," %(index)d # %(name)ls")	
      commentline0 = Blueprint(Item,"# %(comment)ls")
      commentline = Blueprint(Item," # %(comment)ls")
      commentline2 = Blueprint(Item," #%(comment)ls")
      #itemtype5,itemtype6
      #itemtype7,itemtype8,itemtype9
      items += [itemtype2,itemtype1,itemtype3,itemtype4,itemtype5,itemtype6,
		blankitem,commentline0,commentline,commentline2] # the order here could make a difference to performance (should it be items+[ ] or [ ]+items?)
      blocktype1 = Blueprint(Block,"BLOCK %(name)s %(value)d # %(comment)ls")
      blocktype2 = Blueprint(Block,"BLOCK %(name)s # %(comment)ls")
      #WARNING!!! blocktype 3 didn't solve my problem: had lines in a file like:
      # Block CROSSSECTIONS   #LSP-nucleon spin independent (SI) and dependent (SD) sigmas
      #the lack of a space after the hash before the comment was killing the code; tried to add blocktype3
      #to compensate but didn't work. Had to changed the file to avoid problem. 
      blocktype3 = Blueprint(Block,"BLOCK %(name)s #%(comment)ls")  #bjf> spaces can cause errors apparently if not in the file
      #blocktype10 = Blueprint(Block,"Block %(name)s #%(comment)ls")  #bjf> spaces can cause errors apparently if not in the file
      blocktype4 = Blueprint(Block,"BLOCK %(name)s")
      blocktype5 = Blueprint(Block,"BLOCK %(name)s Q= %(value)e # %(comment)ls")    #bjf> added extra blocktype to deal with some of the softsusy blocks
      blocktype6 = Blueprint(Block,"BLOCK %(name)s Q=%(value)e # %(comment)ls")    #bjf> added extra blocktype to deal with some of the softsusy blocks
      blocktype7 = Blueprint(Block,"BLOCK %(name)s Q= %(value)e")    #bjf> Need one to have no comment as well
      #bjf> need blueprints to account for possible spaces before BLOCK
      standardblocks += [blocktype1,blocktype2,blocktype3,blocktype4,blocktype5,blocktype6,blocktype7]
      for block in standardblocks: block.subblueprints += items
      self.items = items
      self.standardblocks = standardblocks
Exemplo n.º 2
0
 def copyto(self,path):
    f = open(SUSYFile.add_suffix(path),"wb")
    # print 'slhacopying', SUSYFile.add_suffix(path)
    for block in self.data:
       f.write(str(block))