Ejemplo n.º 1
0
    def ExistsTypedProperty(self,
                            id,
                            location=None,
                            _type=None,
                            prefix=True,
                            propertiesInstance=None):
        """
        Determines if the stream with the provided id exists in the location specified.
        If no location is specified, the root directory is searched. The return of this
        function is 2 values, the first being a boolean for if anything was found, and
        the second being how many were found.

        Because of how this function works, any folder that contains it's own
        "__properties_version1.0" file should have this function called from it's class.
        """
        verifyPropertyId(id)
        verifyType(_type)
        id = id.upper()
        if propertiesInstance is None:
            propertiesInstance = self.mainProperties
        prefixList = self.prefixList if prefix else []
        if location is not None:
            prefixList.append(location)
        prefixList = inputToMsgpath(prefixList)
        usableid = id + _type if _type is not None else id
        found_number = 0
        found_streams = []
        for item in self.listDir():
            if len(item) > len(prefixList):
                if item[len(prefixList)].startswith(
                        '__substg1.0_' + usableid) and item[len(
                            prefixList)] not in found_streams:
                    found_number += 1
                    found_streams.append(item[len(prefixList)])
        for x in propertiesInstance:
            if x.startswith(usableid):
                already_found = False
                for y in found_streams:
                    if y.endswith(x):
                        already_found = True
                        break
                if not already_found:
                    found_number += 1
        return (found_number > 0), found_number
Ejemplo n.º 2
0
    def _getTypedData(self, id, _type=None):
        """
        Gets the data for the specified id as the type that it is
        supposed to be. :param id: MUST be a 4 digit hexadecimal
        string.

        If you know for sure what type the data is before hand,
        you can specify it as being one of the strings in the
        constant FIXED_LENGTH_PROPS_STRING or
        VARIABLE_LENGTH_PROPS_STRING.
        """
        verifyPropertyId(id)
        id = id.upper()
        found, result = self._getTypedStream('__substg1.0_' + id, _type)
        if found:
            return result
        else:
            found, result = self._getTypedProperty(id, _type)
            return result if found else None
Ejemplo n.º 3
0
    def _getTypedProperty(self, propertyID, _type=None):
        """
        Gets the property with the specified id as the type that it
        is supposed to be. :param id: MUST be a 4 digit hexadecimal
        string.

        If you know for sure what type the property is before hand,
        you can specify it as being one of the strings in the
        constant FIXED_LENGTH_PROPS_STRING or
        VARIABLE_LENGTH_PROPS_STRING.
        """
        verifyPropertyId(propertyID)
        verifyType(_type)
        propertyID = propertyID.upper()
        for x in (propertyID + _type, ) if _type is not None else self.props:
            if x.startswith(propertyID):
                prop = self.props[x]
                return True, (prop.value
                              if isinstance(prop, FixedLengthProp) else prop)
        return False, None