Ejemplo n.º 1
0
    def unbury_metadata(self, a_id, a_id_dir=None):
        """
           Get metadata info from DB
        """
        if not a_id_dir:
            a_id_dir = self.get_directory_from_id(a_id)

        with self._get_metadata_file_from_id(a_id_dir, a_id) as f:
            metadata = json.load(f)

        metadata[self.INT_DATE_K] = gmvault_utils.e2datetime(
            metadata[self.INT_DATE_K])
        
        # force conversion of labels as string because IMAPClient
        # returns a num when the label is a number (ie. '00000') and handle utf-8
        new_labels = []

        for label in metadata[self.LABELS_K]:
            if isinstance(label, (int, long, float, complex)):
                label = str(label)
            new_labels.append(unicode(label))
 
        metadata[self.LABELS_K] = new_labels

        return metadata
Ejemplo n.º 2
0
    def unbury_metadata(self, a_id, a_id_dir = None):
        """
           Get metadata info from DB
        """
        if not a_id_dir:
            a_id_dir = self.get_directory_from_id(a_id)
        
        meta_fd = self._get_metadata_file_from_id(a_id_dir, a_id)
    
        metadata = json.load(meta_fd)
        
        metadata[self.INT_DATE_K] =  gmvault_utils.e2datetime(metadata[self.INT_DATE_K])
        
        # force convertion of labels as string because IMAPClient
        # returns a num when the label is a number (ie. '00000') and handle utf-8
        new_labels = []

        for label in  metadata[self.LABELS_K]:
            if isinstance(label, (int, long, float, complex)):
                label = str(label)
            new_labels.append(unicode(label))
 
        metadata[self.LABELS_K] = new_labels

        return metadata