Exemplo n.º 1
0
 def __init__(self):
     self.__library = System.Collections.ArrayList()
     self.__libraryView = System.Collections.ArrayList()
     self.SearchFilter = SearchFilter(self)
     self._events = []
Exemplo n.º 2
0
    def searchAndFilter(self):
        """
            search or filter the method/class/string in the line Edit.
        """
        target = self.lineEdit.text()
        option = 0

        if self.radioButton_filter.isChecked():
            option = 1
        elif self.radioButton_search.isChecked():
            option = 2

        currentIndex = self.tabWidget_2.currentIndex()
        if currentIndex not in [0, 1, 2, 3]:
            return

        if currentIndex == 3:
            searchFilter = SearchFilter(self.treeWidget_methods, target)
        elif currentIndex == 2:
            searchFilter = SearchFilter(self.listWidget_classes, target)
        elif currentIndex == 1:
            searchFilter = SearchFilter(self.listWidget_strings, target)
        elif currentIndex == 0:
            searchFilter = SearchFilter(self.treeWidget_files, target)

        if option == 1:
            if currentIndex == 3 or currentIndex == 0:
                searchFilter.filter_treewidget()
            elif currentIndex == 2 or currentIndex == 1:
                searchFilter.filter_listwidget()
        elif option == 2:
            if currentIndex == 3 or currentIndex == 0:
                searchFilter.search_treewidget()
            elif currentIndex == 2 or currentIndex == 1:
                searchFilter.search_listwidget()
Exemplo n.º 3
0
class Library(INotifyPropertyChanged):
    "class that represents the user's library"

    class Song:
        def __init__(self, path):
            self.Path = path
            self.Title = Path.GetFileName(path)

        def matches(self, string):
            strU = string.ToUpper()
            return self.Title.ToUpper().Contains(strU)

    def __init__(self):
        self.__library = System.Collections.ArrayList()
        self.__libraryView = System.Collections.ArrayList()
        self.SearchFilter = SearchFilter(self)
        self._events = []

    def add_PropertyChanged(self, value):
        self._events.append(value)

    def remove_PropertyChanged(self, value):
        self._events.remove(value)

    def NotifyPropertyChanged(self, info):
        for x in self._events:
            x(self, PropertyChangedEventArgs(info))

    def AddDir(self, StartDir):
        AllDirs = System.IO.Directory.GetDirectories(StartDir)

        try:
            for dir in AllDirs:
                self.AddDir(dir)
        except Exception:
            pass

        for extension in ["*.mp3", "*.wma"]:
            AllSongs = System.IO.Directory.GetFiles(StartDir, extension)
            for a in AllSongs:
                self.AddFile(a)

    def AddFile(self, file):
        song = Library.Song(file)
        self.__library.Add(song)
        self.updateLibraryView()

    def updateLibraryView(self):
        self.__libraryView = self.SearchFilter.applyFilterAndSort(
            self.__library)
        self.NotifyPropertyChanged("LibraryView")

    def getLibraryView(self):
        return self.__libraryView

    def ViewIndexOf(self, value):
        return self.__libraryView.IndexOf(value)

    def ViewGetValue(self, index):
        if ((index >= 0) and (index < self.__libraryView.Count)):
            return self.__libraryView[index]
        else:
            return None
Exemplo n.º 4
0
 def searchAndFilter(self):
     """
         search or filter the method/class/string in the line Edit.
     """
     target = self.lineEdit.text()
     option = 0
     
     if self.radioButton_filter.isChecked():
         option = 1
     elif self.radioButton_search.isChecked():
         option = 2
     
     currentIndex = self.tabWidget_2.currentIndex()
     if currentIndex not in [0, 1, 2, 3]:
         return
     
     if currentIndex == 3:
         searchFilter = SearchFilter(self.treeWidget_methods, target)
     elif currentIndex == 2:
         searchFilter = SearchFilter(self.listWidget_classes, target)
     elif currentIndex == 1:
         searchFilter = SearchFilter(self.listWidget_strings, target)
     elif currentIndex == 0:
         searchFilter = SearchFilter(self.treeWidget_files, target)
     
     if option == 1:
         if currentIndex == 3 or currentIndex == 0:
             searchFilter.filter_treewidget()
         elif currentIndex == 2 or currentIndex == 1:
             searchFilter.filter_listwidget()
     elif option ==2:
         if currentIndex == 3 or currentIndex == 0:
             searchFilter.search_treewidget()
         elif currentIndex == 2 or currentIndex == 1:
             searchFilter.search_listwidget()
Exemplo n.º 5
0
 def __init__(self):
     self.__library = System.Collections.ArrayList()
     self.__libraryView = System.Collections.ArrayList()
     self.SearchFilter = SearchFilter(self)
     self._events = []
Exemplo n.º 6
0
class Library(INotifyPropertyChanged):
    "class that represents the user's library"
    
    class Song:
        def __init__(self,path):
            self.Path = path
            self.Title = Path.GetFileName(path)
        def matches(self,string):
            strU = string.ToUpper()
            return self.Title.ToUpper().Contains(strU)
    
    def __init__(self):
        self.__library = System.Collections.ArrayList()
        self.__libraryView = System.Collections.ArrayList()
        self.SearchFilter = SearchFilter(self)
        self._events = []
    
    def add_PropertyChanged(self, value):
        self._events.append(value)

    def remove_PropertyChanged(self, value):
        self._events.remove(value)

    def NotifyPropertyChanged(self, info):
        for x in self._events:
            x(self,PropertyChangedEventArgs(info))
    
    def AddDir(self,StartDir):
        AllDirs = System.IO.Directory.GetDirectories(StartDir)
        
        try:
            for dir in AllDirs:
                self.AddDir(dir)
        except Exception:
            pass
            
        for extension in ["*.mp3","*.wma"]:
            AllSongs = System.IO.Directory.GetFiles(StartDir, extension)
            for a in AllSongs:
                self.AddFile(a)
        
    def AddFile(self,file):
        song = Library.Song(file)
        self.__library.Add(song)
        self.updateLibraryView()
        
    def updateLibraryView(self):
        self.__libraryView = self.SearchFilter.applyFilterAndSort(self.__library)
        self.NotifyPropertyChanged("LibraryView")
    
    def getLibraryView(self):
        return self.__libraryView
        
    def ViewIndexOf(self,value):
        return self.__libraryView.IndexOf(value)
        
    def ViewGetValue(self,index):
        if ((index >= 0) and (index < self.__libraryView.Count)):
            return self.__libraryView[index]
        else:
            return None
Exemplo n.º 7
0
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err)  # will print something like "option -a not recognized"
        usage()
        sys.exit(2)

    opts = dict(opts)
    if '-h' in opts or '--help' in opts or '-v' in opts:
        usage()
        sys.exit(0)
    opts['--query'] = '&'.join(opts['--query'].split())
    filter = SearchFilter.SearchFilter(
        opts['--query'],
        opts['--category'],
        opts['--sentiment'],
        opts['--startdate'],
        opts['--enddate'],
        int(opts['--randomseed']),
        int(opts['--limit']),
    )
    type = 'solr'
    connection = SearchFilter.Connection(type)
    if '--blog' in opts:
        print 'fetching blog'
        print '\n'.join(connection.getBlog(filter))
    else:
        print 'fetching post'
        for elt in connection.getBlogPost(filter):
            print elt