Home | Trees | Indices | Help |
---|
|
1 ################################################################################ 2 # Ganga Project. http://cern.ch/ganga 3 # 4 # $Id: FileBuffer.py,v 1.1 2008-07-17 16:40:53 moscicki Exp $ 5 ################################################################################ 6 7 import os9 """ FileBuffer represents a file in memory which has not been yet created. 10 This is a handy way of creating small wrapper scripts to be generated on the fly. 11 """ 12 13 # Added a subdir (see File.py for comments) - AM48 49 50 51 # 52 # 53 # 54 # $Log: not supported by cvs2svn $ 55 # Revision 1.5 2007/08/28 08:26:35 moscicki 56 # fixed typo 57 # 58 # Revision 1.4 2005/08/23 17:07:23 moscicki 59 # Added executable flag for FileBuffer. 60 # Added create method for File and FileBuffer. 61 # Added getPathInSandbox() method. 62 # 63 # Revision 1.3 2005/08/10 09:45:36 andrew 64 # Added a subdir to File and FileBuffer objects. Changed the writefile method 65 # in FileWorspace to use the subdirectory 66 # 67 # 68 # 69 # 7015 """ name is the name of the file to be created 16 contents is the text with file contents or a file-object which will be read() 17 executable indicates if a file is create()'ed with executable permissions 18 """ 19 self.name = name 20 self._contents = contents 21 self.subdir=subdir 22 self.executable=executable2325 """return a relative location of a file in a sandbox: subdir/name""" 26 from Ganga.Utility.files import real_basename 27 return self.subdir+os.sep+real_basename(self.name)2830 """return a string with the contents of the file buffer""" 31 if type(self._contents) is type(''): 32 return self._contents 33 else: 34 return self._contents.read()3537 """create a file in a local filesystem as 'outname' """ 38 file(outname,'w').write(self.getContents()) 39 40 if self.executable: 41 from Ganga.Utility.files import chmod_executable 42 chmod_executable(outname)43 4446 """ return true if a file is create()'ed with executable permissions""" 47 return self.executable
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Jun 25 10:35:25 2012 | http://epydoc.sourceforge.net |