A method to parse a Volume Descriptor Set Terminator out of a string.

        Parameters:
         vd - The string to parse.
         extent_loc - The extent this VDST is currently located at.
        Returns:
         Nothing.
518459
def parse(self, vd, extent_loc):
        # type: (bytes, int) -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Volume Descriptor Set Terminator already initialized')

        (descriptor_type, identifier, version,
         zero_unused) = struct.unpack_from(self.FMT, vd, 0)

        # According to Ecma-119, 8.3.1, the volume descriptor set terminator
        # type should be 255
        if descriptor_type != VOLUME_DESCRIPTOR_TYPE_SET_TERMINATOR:
            raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST descriptor type')
        # According to Ecma-119, 8.3.2, the identifier should be 'CD001'
        if identifier != b'CD001':
            raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST identifier')
        # According to Ecma-119, 8.3.3, the version should be 1
        if version != 1:
            raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST version')
        # According to Ecma-119, 8.3.4, the rest of the terminator should be 0;
        # however, we have seen ISOs in the wild that put stuff into this field.
        # Just ignore it.

        self.orig_extent_loc = extent_loc

        self._initialized = True
700943
def _seek_to_extent(self, extent):
        # type: (int) -> None
        '''
        
        '''
        self._cdfp.seek(extent * self.pvd.logical_block_size())
28499
def loc(lexer: Lexer, start_token: Token) -> Optional[Location]:
    
    if not lexer.no_location:
        end_token = lexer.last_token
        source = lexer.source
        return Location(
            start_token.start, end_token.end, start_token, end_token, source
        )
    return None
508129
function(d, val) {
    return later.wm.val(d) === (val || later.wm.extent(d)[1]);
  }
616536
def extent_all(self):
		
		segs = tuple(seglist.extent() for seglist in self.values() if seglist)
		if not segs:
			raise ValueError("empty list")
		return segment(min(seg[0] for seg in segs), max(seg[1] for seg in segs))
1067867
def make_nd_vec(v, nd=None, t=None, norm=False):
    

    # Imports
    import numpy as np
    from scipy import linalg as spla

    # Reduce the input to the extent possible
    out_v = np.array(v, dtype=t).squeeze()

    # Confirm vector form
    if not len(out_v.shape) == 1:
        raise ValueError("'v' is not reducible to a vector.")
    ## end if

    # If indicated, confirm dimensionality
    if nd and not out_v.shape[0] == nd:
        raise ValueError("'v' dimension is " + str(out_v.shape[0]) +
                ", not " + str(nd))
    ## end if

    # Normalize, if indicated
    if norm:
        out_v = out_v / spla.norm(out_v)
    ## end if

    # Return result
    return out_v
1205065
def detect(self, volume_system, vstype='detect'):
        """"""

        volume_group = volume_system.parent.info.get('volume_group')

        result = _util.check_output_(["lvm", "lvdisplay", volume_group])
        cur_v = None
        for l in result.splitlines():
            if "--- Logical volume ---" in l:
                cur_v = volume_system._make_subvolume(
                    index=self._format_index(volume_system, len(volume_system)),
                    flag='alloc'
                )
                cur_v.info['fsdescription'] = 'Logical Volume'
            if "LV Name" in l:
                cur_v.info['label'] = l.replace("LV Name", "").strip()
            if "LV Size" in l:
                size, unit = l.replace("LV Size", "").strip().split(" ", 1)
                cur_v.size = int(float(size.replace(',', '.')) * {'KiB': 1024, 'MiB': 1024 ** 2,
                                                                  'GiB': 1024 ** 3, 'TiB': 1024 ** 4}.get(unit, 1))
            if "LV Path" in l:
                cur_v._paths['lv'] = l.replace("LV Path", "").strip()
                cur_v.offset = 0

        logger.info("{0} volumes found".format(len(volume_system)))
        volume_system.volume_source = 'multi'
        return volume_system.volumes
1184501
def parse(self, vd, extent_loc):
        # type: (bytes, int) -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Boot Record already initialized')

        (descriptor_type, identifier, version,
         self.boot_system_identifier, self.boot_identifier,
         self.boot_system_use) = struct.unpack_from(self.FMT, vd, 0)

        # According to Ecma-119, 8.2.1, the boot record type should be 0
        if descriptor_type != VOLUME_DESCRIPTOR_TYPE_BOOT_RECORD:
            raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record descriptor type')
        # According to Ecma-119, 8.2.2, the identifier should be 'CD001'
        if identifier != b'CD001':
            raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record identifier')
        # According to Ecma-119, 8.2.3, the version should be 1
        if version != 1:
            raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record version')

        self.orig_extent_loc = extent_loc

        self._initialized = True
840807
def detect(self, volume_system, vstype='detect'):
        """"""

        # Loop over all volumes in image.
        for p in self._find_volumes(volume_system, vstype):
            import pytsk3

            volume = volume_system._make_subvolume(
                index=self._format_index(volume_system, p.addr),
                offset=p.start * volume_system.disk.block_size,
                size=p.len * volume_system.disk.block_size
            )
            # Fill volume with more information
            volume.info['fsdescription'] = p.desc.strip().decode('utf-8')

            if p.flags == pytsk3.TSK_VS_PART_FLAG_ALLOC:
                volume.flag = 'alloc'
                volume.slot = _util.determine_slot(p.table_num, p.slot_num)
                volume_system._assign_disktype_data(volume)
                logger.info("Found allocated {2}: block offset: {0}, length: {1} ".format(p.start, p.len,
                                                                                          volume.info['fsdescription']))
            elif p.flags == pytsk3.TSK_VS_PART_FLAG_UNALLOC:
                volume.flag = 'unalloc'
                logger.info("Found unallocated space: block offset: {0}, length: {1} ".format(p.start, p.len))
            elif p.flags == pytsk3.TSK_VS_PART_FLAG_META:
                volume.flag = 'meta'
                logger.info("Found meta volume: block offset: {0}, length: {1} ".format(p.start, p.len))

            yield volume
273294
def _file_loc(self):
        
        if self.__fname is None:
            f = os.path.splitext(os.path.basename(argv[0]))[0] + '.ini'
            cwd = os.getcwd()
            # todo: prefer script path or current path ??
            # print(os.path.realpath(sys.argv[0]))
            # todo: if os.path.exists(os.path.join(cwd, main.__file__)):
            return os.path.join(cwd, f)
        return self.__fname
5637
private void parseExtension(Extension ext) throws IOException {
        try {
            Class<?> extClass = OIDMap.getClass(ext.getExtensionId());
            if (extClass == null) {   // Unsupported extension
                if (ext.isCritical()) {
                    unsupportedCritExt = true;
                }
                if (map.put(ext.getExtensionId().toString(), ext) == null) {
                    return;
                } else {
                    throw new IOException("Duplicate extensions not allowed");
                }
            }
            Constructor<?> cons = extClass.getConstructor(PARAMS);

            Object[] passed = new Object[] {Boolean.valueOf(ext.isCritical()),
                    ext.getExtensionValue()};
                    CertAttrSet<?> certExt = (CertAttrSet<?>)
                            cons.newInstance(passed);
                    if (map.put(certExt.getName(), (Extension)certExt) != null) {
                        throw new IOException("Duplicate extensions not allowed");
                    }
        } catch (InvocationTargetException invk) {
            Throwable e = invk.getTargetException();
            if (ext.isCritical() == false) {
                // ignore errors parsing non-critical extensions
                if (unparseableExtensions == null) {
                    unparseableExtensions = new TreeMap<String,Extension>();
                }
                unparseableExtensions.put(ext.getExtensionId().toString(),
                        new UnparseableExtension(ext, e));
                if (debug != null) {
                    debug.println("Error parsing extension: " + ext);
                    e.printStackTrace();
                    HexDumpEncoder h = new HexDumpEncoder();
                    System.err.println(h.encodeBuffer(ext.getExtensionValue()));
                }
                return;
            }
            if (e instanceof IOException) {
                throw (IOException)e;
            } else {
                throw new IOException(e);
            }
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
489869
def extent_count(self):
        
        self.open()
        count = lvm_vg_get_extent_count(self.handle)
        self.close()
        return count
808021
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Descriptor not initialized')

        rec = struct.pack(self.FMT, b'\x00' * 16, self.main_vd_length,
                          self.main_vd_extent, self.reserve_vd_length,
                          self.reserve_vd_extent)[16:] + b'\x00' * 480

        return self.desc_tag.record(rec) + rec
143394
def update_extent(self, extent):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')

        self.bl_cont_area = extent
385485
def _get_storage_vol(conn, pool, vol):
    '''
    
    '''
    pool_obj = conn.storagePoolLookupByName(pool)
    return pool_obj.storageVolLookupByName(vol)
1041405
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor not initialized')

        rec = struct.pack(self.FMT, b'\x00' * 16,
                          self.vol_desc_seqnum, self.desc_num,
                          self.vol_ident, 1, 1, 2, self.max_interchange_level, 1, 1,
                          self.vol_set_ident,
                          self.desc_char_set, self.explanatory_char_set,
                          self.vol_abstract_length, self.vol_abstract_extent,
                          self.vol_copyright_length, self.vol_copyright_extent,
                          self.app_ident.record(), self.recording_date.record(),
                          self.impl_ident.record(), self.implementation_use,
                          self.predecessor_vol_desc_location, 0, b'\x00' * 22)[16:]
        return self.desc_tag.record(rec) + rec
353469
def get_loc(self, key, method=None, tolerance=None):
        """"""
        if isinstance(key, str):
            return self._get_string_slice(key)
        else:
            return pd.Index.get_loc(self, key, method=method,
                                    tolerance=tolerance)