def loadmetadata(self):
        """Load metadata for this file. This is usually called automatically upon instantiation, except if explicitly disabled. Works both locally as well as for clients connecting to a CLAM service."""
        if not self.remote:
            metafile = self.projectpath + self.basedir + '/' + self.metafilename()
            if os.path.exists(metafile):
                f = io.open(metafile, 'r',encoding='utf-8')
                xml = "".join(f.readlines())
                f.close()
            else:
                raise IOError(2, "No metadata found, expected " + metafile )
        else:
            if self.client:
                requestparams = self.client.initrequest()
            else:
                requestparams = {}
            response = requests.get(self.projectpath + self.basedir + '/' + self.filename + '/metadata', **requestparams)
            if response.status_code != 200:
                extramsg = ""
                if not self.client: extramsg = "No client was associated with this CLAMFile, associating a client is necessary when authentication is needed"
                raise HTTPError(2, "Can't download metadata for " + self.filename + ". " + extramsg)
            xml = response.text


        #parse metadata
        try:
            self.metadata = CLAMMetaData.fromxml(xml, self) #returns CLAMMetaData object (or child thereof)
        except ElementTree.XMLSyntaxError:
            raise ValueError("Metadata is not XML! Contents: " + xml)
def loadmetadata ( self ) : if not self . remote : metafile = self . projectpath + self . basedir + '/' + self . metafilename ( ) if os . path . exists ( metafile ) : f = io . open ( metafile , 'r' , encoding = 'utf-8' ) xml = "" . join ( f . readlines ( ) ) f . close ( ) else : raise IOError ( 2 , "No metadata found, expected " + metafile ) else : if self . client : requestparams = self . client . initrequest ( ) else : requestparams = { } response = requests . get ( self . projectpath + self . basedir + '/' + self . filename + '/metadata' , ** requestparams ) if response . status_code != 200 : extramsg = "" if not self . client : extramsg = "No client was associated with this CLAMFile, associating a client is necessary when authentication is needed" raise HTTPError ( 2 , "Can't download metadata for " + self . filename + ". " + extramsg ) xml = response . text try : self . metadata = CLAMMetaData . fromxml ( xml , self ) except ElementTree . XMLSyntaxError : raise ValueError ( "Metadata is not XML! Contents: " + xml )
Load metadata for this file. This is usually called automatically upon instantiation, except if explicitly disabled. Works both locally as well as for clients connecting to a CLAM service.