<s> from __future__ import division <EOL> from vistrails . core . db . locator import BaseLocator <EOL> from vistrails . core . system import strftime <EOL> from datetime import datetime <EOL> class Entity ( object ) : <EOL> DATE_FORMAT = '<STR_LIT>' <EOL> def __init__ ( self ) : <EOL> self . parent = None <EOL> self . children = [ ] <EOL> self . image_fnames = [ ] <EOL> self . was_updated = False <EOL> self . is_open = False <EOL> def load ( self , * args ) : <EOL> ( self . id , <EOL> _ , <EOL> self . name , <EOL> self . user , <EOL> self . mod_time , <EOL> self . create_time , <EOL> self . size , <EOL> self . description , <EOL> self . url ) = args <EOL> self . mod_time = self . timeval ( self . mod_time ) <EOL> self . create_time = self . timeval ( self . create_time ) <EOL> def save ( self ) : <EOL> return ( self . id , <EOL> self . type_id , <EOL> self . name , <EOL> self . user , <EOL> strftime ( self . mod_time , self . DATE_FORMAT ) , <EOL> strftime ( self . create_time , self . DATE_FORMAT ) , <EOL> self . size , <EOL> self . description , <EOL> self . url ) <EOL> def _get_start_date ( self ) : <EOL> return self . create_time <EOL> start_date = property ( _get_start_date ) <EOL> def _get_end_date ( self ) : <EOL> return self . mod_time <EOL> end_date = property ( _get_end_date ) <EOL> def now ( self ) : <EOL> return datetime . now ( ) <EOL> def timeval ( self , time ) : <EOL> try : <EOL> return datetime . strptime ( time , self . DATE_FORMAT ) <EOL> except ValueError : <EOL> try : <EOL> return datetime . strptime ( time , '<STR_LIT>' ) <EOL> except ValueError : <EOL> return self . now ( ) <EOL> def match ( self , search ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> def locator ( self ) : <EOL> locator = BaseLocator . from_url ( self . url ) <EOL> return locator </s>
