def _updateFromFS(self, force=0): if force or Globals.DevelopmentMode: fp = expandpath(self._filepath) try: mtime=stat(fp)[8] except: mtime=0 if force or mtime != self._file_mod_time: self._file_mod_time = mtime fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() self._write(data) self._makeFunction(1)
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() if reparse: self.write(data)
def _readFile(self): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() (self.content_type, self.width, self.height) = getImageInfo(data) return data
def get_size(self): """Get the size of a file or image. Returns the size of the file or image. """ fp = expandpath(self._filepath) return path.getsize(fp)
def _updateFromFS(self): if Globals.DevelopmentMode: fp = expandpath(self._filepath) try: mtime=stat(fp)[8] except: mtime=0 if mtime != self._file_mod_time: self._file_mod_time = mtime self._readFile(1)
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() self.raw = data if reparse: self.cook()
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() if reparse or self.content_type == 'unknown/unknown': self.ZCacheable_invalidate() self.content_type=self._get_content_type(file, data, self.id) return data
def _readFile(self, reparse): """Read the data from the filesystem. Read the file (indicated by exandpath(self._filepath), and parse the data if necessary. """ fp = expandpath(self._filepath) file = open(fp, 'r') try: data = file.read() finally: file.close() self._write(data)
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() if reparse or self.content_type == 'unknown/unknown': ct, width, height = getImageInfo( data ) self.content_type = ct self.width = width self.height = height return data
def __init__(self, id, filepath, fullname=None, properties=None): if properties: # Since props come from the filesystem, this should be # safe. self.__dict__.update(properties) self._filepath = filepath data = self._readFile() fp = expandpath(filepath) try: self.file_mod_time = stat(fp)[8] except: pass HTML.__init__(self, data, __name__=id)
def __init__(self, id, filepath, fullname=None, properties=None): if properties: # Since props come from the filesystem, this should be # safe. self.__dict__.update(properties) self.__name__ = fullname or id # Use the whole filename. self.title = '' self._filepath = filepath fp = expandpath(self._filepath) try: self.file_mod_time = stat(fp)[8] except: pass self._readFile()
def _readFile( self, reparse ): fp = expandpath( self._filepath ) file = open( fp, 'r' ) # not binary, we want CRLF munging here. try: data = file.read() finally: file.close() self.raw = data if reparse: self.cook()
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = self._data = file.read() finally: file.close() if reparse or self.content_type == 'unknown/unknown': self.ZCacheable_invalidate() ct, width, height = getImageInfo(data) self.content_type = ct self.width = width self.height = height return data
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'r') # not 'rb', as this is a text file! try: data = file.read() finally: file.close() self.raw = data if reparse: self._reading = 1 # Avoid infinite recursion try: self.cook() finally: self._reading = 0
def _readFile(self, reparse): """Read the data from the filesystem. Read the file (indicated by exandpath(self._filepath), and parse the data if necessary. """ fp = expandpath(self._filepath) file = open(fp, 'r') try: data = file.read() finally: file.close() if reparse: self._write(data, reparse)
def _readFile(self, reparse): """Read the data from the filesystem. Read the file (indicated by exandpath(self._filepath), and parse the data if necessary. """ fp = expandpath(self._filepath) file = open(fp, 'r') # not 'rb', as this is a text file! try: lines = file.readlines() finally: file.close() map = [] lino = 0 for line in lines: lino = lino + 1 line = line.strip() if not line or line[0] == '#': continue try: propname, proptv = line.split(':', 1) #XXX multi-line properties? proptype, propvstr = proptv.split('=', 1) propname = propname.strip() proptype = proptype.strip() propvstr = propvstr.strip() converter = get_converter(proptype, lambda x: x) propvalue = converter(propvstr) # Should be safe since we're loading from # the filesystem. setattr(self, propname, propvalue) map.append({ 'id': propname, 'type': proptype, 'mode': '', 'default_value': propvalue, }) except: raise ValueError, ('Error processing line %s of %s:\n%s' % (lino, fp, line)) self._properties = tuple(map)
def _readFile(self, reparse): """Read the data from the filesystem. Read the file (indicated by exandpath(self._filepath), and parse the data if necessary. """ fp = expandpath(self._filepath) file = open(fp, 'rb') try: lines = file.readlines() finally: file.close() map = [] lino=0 for line in lines: lino = lino + 1 line = strip( line ) if not line or line[0] == '#': continue try: propname, proptv = split( line, ':' ) #XXX multi-line properties? proptype, propvstr = proptv.split( '=', 1 ) propname = strip(propname) proptype = strip(proptype) propvstr = strip(propvstr) converter = get_converter( proptype, lambda x: x ) propvalue = converter( strip( propvstr ) ) # Should be safe since we're loading from # the filesystem. setattr(self, propname, propvalue) map.append({'id':propname, 'type':proptype, 'mode':'', 'default_value':propvalue, }) except: raise ValueError, ( 'Error processing line %s of %s:\n%s' % (lino,fp,line) ) self._properties = tuple(map)
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'r') # not 'rb', as this is a text file! try: data = file.read() finally: file.close() if reparse: if xml_detect_re.match(data): # Smells like xml self.content_type = 'text/xml' else: try: del self.content_type except (AttributeError, KeyError): pass self.write(data)
def _readFile(self): fp = expandpath(self._filepath) file = open(fp, 'rb') try: lines = file.readlines() finally: file.close() map = [] for line in lines: propname, proptv = split( line, ':' ) #XXX multi-line properties? proptype, propvstr = split( proptv, '=' ) propname = strip(propname) proptv = strip(proptv) propvstr = strip(propvstr) converter = get_converter( proptype, lambda x: x ) propvalue = converter( strip( propvstr ) ) # Should be safe since we're loading from # the filesystem. setattr(self, propname, propvalue) map.append({'id':propname, 'type':proptype, 'mode':'', 'default_value':propvalue, }) self._properties = tuple(map)
def _readFile( self, reparse ): fp = expandpath( self._filepath ) file = open( fp, 'r' ) parameters = {} try: for line in file.readlines(): line = line.strip() if not line: continue if line[0] == '#': continue key, value = line.split(':') parameters[key.strip()] = value.strip() finally: file.close() for k in parameters.keys(): if k not in self.allowed_params: del parameters[k] self.manage_edit(**parameters)
def get_size(self): """Get the size of the underlying file.""" fp = expandpath(self._filepath) return path.getsize(fp)
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() self.write(data)
def _readFile(self): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() return data