<s> """<STR_LIT>""" <EOL> from dfdatetime import posix_time as dfdatetime_posix_time <EOL> from dfvfs . lib import definitions <EOL> from dfvfs . lib import errors <EOL> from dfvfs . lib import lvm <EOL> from dfvfs . path import lvm_path_spec <EOL> from dfvfs . vfs import file_entry <EOL> from dfvfs . vfs import vfs_stat <EOL> class LVMDirectory ( file_entry . Directory ) : <EOL> """<STR_LIT>""" <EOL> def _EntriesGenerator ( self ) : <EOL> """<STR_LIT>""" <EOL> volume_index = getattr ( self . path_spec , u'<STR_LIT>' , None ) <EOL> if volume_index is not None : <EOL> return <EOL> location = getattr ( self . path_spec , u'<STR_LIT:location>' , None ) <EOL> if location is None or location != self . _file_system . LOCATION_ROOT : <EOL> return <EOL> vslvm_volume_group = self . _file_system . GetLVMVolumeGroup ( ) <EOL> for volume_index in range ( <NUM_LIT:0> , vslvm_volume_group . number_of_logical_volumes ) : <EOL> yield lvm_path_spec . LVMPathSpec ( <EOL> location = u'<STR_LIT>' . format ( volume_index + <NUM_LIT:1> ) , <EOL> parent = self . path_spec . parent , volume_index = volume_index ) <EOL> class LVMFileEntry ( file_entry . FileEntry ) : <EOL> """<STR_LIT>""" <EOL> TYPE_INDICATOR = definitions . TYPE_INDICATOR_LVM <EOL> def __init__ ( <EOL> self , resolver_context , file_system , path_spec , is_root = False , <EOL> is_virtual = False ) : <EOL> """<STR_LIT>""" <EOL> super ( LVMFileEntry , self ) . __init__ ( <EOL> resolver_context , file_system , path_spec , is_root = is_root , <EOL> is_virtual = is_virtual ) <EOL> self . _name = None <EOL> def _GetDirectory ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _stat_object is None : <EOL> self . _stat_object = self . _GetStat ( ) <EOL> if ( self . _stat_object and <EOL> self . _stat_object . type == self . _stat_object . TYPE_DIRECTORY ) : <EOL> return LVMDirectory ( self . _file_system , self . path_spec ) <EOL> return <EOL> def _GetStat ( self ) : <EOL> """<STR_LIT>""" <EOL> vslvm_logical_volume = self . GetLVMLogicalVolume ( ) <EOL> if not self . _is_virtual and vslvm_logical_volume is None : <EOL> raise errors . BackEndError ( <EOL> u'<STR_LIT>' ) <EOL> stat_object = vfs_stat . VFSStat ( ) <EOL> if vslvm_logical_volume is not None : <EOL> stat_object . size = vslvm_logical_volume . size <EOL> if vslvm_logical_volume is not None : <EOL> timestamp = None <EOL> if timestamp is not None : <EOL> date_time_values = dfdatetime_posix_time . PosixTimestamp ( timestamp ) <EOL> stat_time , stat_time_nano = date_time_values . CopyToStatTimeTuple ( ) <EOL> if stat_time is not None : <EOL> stat_object . crtime = stat_time <EOL> stat_object . crtime_nano = stat_time_nano <EOL> if self . _is_virtual : <EOL> stat_object . type = stat_object . TYPE_DIRECTORY <EOL> else : <EOL> stat_object . type = stat_object . TYPE_FILE <EOL> return stat_object <EOL> @ property <EOL> def name ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _name is None : <EOL> location = getattr ( self . path_spec , u'<STR_LIT:location>' , None ) <EOL> if location is not None : <EOL> self . _name = self . _file_system . BasenamePath ( location ) <EOL> else : <EOL> volume_index = getattr ( self . path_spec , u'<STR_LIT>' , None ) <EOL> if volume_index is not None : <EOL> self . _name = u'<STR_LIT>' . format ( volume_index + <NUM_LIT:1> ) <EOL> else : <EOL> self . _name = u'<STR_LIT>' <EOL> return self . _name <EOL> @ property <EOL> def sub_file_entries ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _directory is None : <EOL> self . _directory = self . _GetDirectory ( ) <EOL> if self . _directory : <EOL> for path_spec in self . _directory . entries : <EOL> yield LVMFileEntry ( self . _resolver_context , self . _file_system , path_spec ) <EOL> def GetLVMLogicalVolume ( self ) : <EOL> """<STR_LIT>""" <EOL> volume_index = lvm . LVMPathSpecGetVolumeIndex ( self . path_spec ) <EOL> if volume_index is None : <EOL> return <EOL> vslvm_volume_group = self . _file_system . GetLVMVolumeGroup ( ) <EOL> return vslvm_volume_group . get_logical_volume ( volume_index ) <EOL> def GetParentFileEntry ( self ) : <EOL> """<STR_LIT>""" <EOL> volume_index = lvm . LVMPathSpecGetVolumeIndex ( self . path_spec ) <EOL> if volume_index is None : <EOL> return <EOL> return self . _file_system . GetRootFileEntry ( ) </s>
