示例#1
0
    def AddNewFiles(self, newpaths):
        '''Add any new files found to the database'''
        def exclude(newpath):
            '''Indicate exclusion based on matching an re in
            IGNOREFILES'''
            f = os.path.basename(newpath)
            for re in IGNOREFILES:
                if re.match(f): return True
            return False

        count = len(newpaths)
        track = 0
        for fp in newpaths:
            track += 1
            if exclude(fp): continue
            # Todo - check handle-able file types
            print 'DOING', fp
            obj = piemeta.get_metadata_object(fp)
            # print 'DOING' obj.FileData_FullPath
            print 'DOING', type(obj.title), obj.title
            print 'DOING', obj, fp
            print '-----'
            obj.add_aspect_stored(fp, sqsess=self.session)
            obj.add_aspect_saved()
            self.session.add(obj)
            newevt = PieFileIndexEvent(
                count=count, track=track,
                message=_('Adding newfound files - %d of %d' % (track, count)))
            wx.PostEvent(self.nwin, newevt)
            print 'AddNewFiles: Adding object %s' % obj
        self.session.commit()
示例#2
0
 def OnFilePicked(self, evt):
     thepath = evt.GetPath()[5:] if evt.GetPath()[:5] == 'file:' else evt.GetPath()
     if not os.path.isfile(thepath): 
         print 'Error reading path'
         self.fntext.SetPath('')
         return
     obj = get_metadata_object(thepath, fakeonly=True)
     if not obj: 
         print 'Unrecognised file type'
         self.fntext.SetPath('')
         return
     self.fntext.SetPath(thepath)
     iconcode = obj.get_icon_code(window_type='filewindow')
     iconp = AtomImageList.GetBitmap(IconType[iconcode])
     self.icon.SetBitmap(iconp)
     self.input.SetFocus()