當前位置: 首頁>>代碼示例>>Python>>正文


Python Category.Category類代碼示例

本文整理匯總了Python中Tribler.Category.Category.Category的典型用法代碼示例。如果您正苦於以下問題:Python Category類的具體用法?Python Category怎麽用?Python Category使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Category類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: toggleFamilyFilter

    def toggleFamilyFilter(self, newState = None, setCheck = False): 
        if newState == None:
            newState = not self.getFamilyFilter()

        Category.getInstance().set_family_filter(newState)
        for l in self.lists:
            if getattr(l, 'GotFilter', False):
                l.GotFilter(None)
                
        if setCheck:
            self.frame.SRstatusbar.ff_checkbox.SetValue(newState)
開發者ID:duy,項目名稱:tribler,代碼行數:11,代碼來源:GuiUtility.py

示例2: set_family_filter

 def set_family_filter(self, enable):
     """
     Set the state of the family filter.
     :param enable: Boolean with the new state.
     :return: Boolean indicating success.
     """
     try:
         Category.getInstance().set_family_filter(enable)
         return True
     except:
         return False
開發者ID:brussee,項目名稱:tsap,代碼行數:11,代碼來源:SettingsManager.py

示例3: __init__

    def __init__(self, parent):
        self.nbdb = NetworkBuzzDBHandler.getInstance()
        self.xxx_filter = Category.getInstance().xxx_filter

        HomePanel.__init__(self, parent, "Click below to explore what's hot", LIST_GREY)

        self.tags = []
        self.buzz_cache = [[],[],[]]
        self.last_shown_buzz = None

        row1_font = self.GetFont()
        row1_font.SetPointSize(row1_font.GetPointSize() + 10)
        row1_font.SetWeight(wx.FONTWEIGHT_BOLD)

        row2_font = self.GetFont()
        row2_font.SetPointSize(row2_font.GetPointSize() + 4)
        row2_font.SetWeight(wx.FONTWEIGHT_BOLD)

        row3_font = self.GetFont()
        row3_font.SetWeight(wx.FONTWEIGHT_BOLD)
        self.TERM_FONTS = [row1_font, row2_font, row3_font]

        self.header.Bind(wx.EVT_ENTER_WINDOW, lambda event: self.OnLeaveWindow())
        self.footer.Bind(wx.EVT_ENTER_WINDOW, lambda event: self.OnLeaveWindow())
        self.panel.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
        self.panel.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)

        self.vSizer.Add(self.getStaticText('...collecting buzz information...'), 0, wx.ALIGN_CENTER)

        self.refresh = 5
        self.GetBuzzFromDB(doRefresh=True)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnRefreshTimer, self.timer)
        self.timer.Start(1000, False)
開發者ID:kenbellows,項目名稱:theglobalsquare,代碼行數:35,代碼來源:home.py

示例4: get_family_filter

 def get_family_filter(self):
     """
     Get the current state of the family filter.
     :return: Boolean indicating state.
     """
     catobj = Category.getInstance()
     return catobj.family_filter_enabled()
開發者ID:brussee,項目名稱:tsap,代碼行數:7,代碼來源:SettingsManager.py

示例5: _connect

    def _connect(self):
        """
        Load database handles and Dispersy.
        :return: Nothing.
        """
        if not self._connected:
            self._connected = True
            self._remote_lock = threading.Lock()

            self._misc_db = self._session.open_dbhandler(NTFY_MISC)
            self._torrent_db = self._session.open_dbhandler(NTFY_TORRENTS)
            self._metadata_db = self._session.open_dbhandler(NTFY_METADATA)
            self._channelcast_db = self._session.open_dbhandler(NTFY_CHANNELCAST)
            self._votecast_db = self._session.open_dbhandler(NTFY_VOTECAST)

            self._category = Category.getInstance()
            self._category_names = {}
            self._xxx_category = -1
            for key, id in self._misc_db._category_name2id_dict.iteritems():
                self._category_names[id] = key

                if key.lower() == "xxx":
                    self._xxx_category = id

            self._dispersy = self._session.lm.dispersy
        else:
            raise RuntimeError('TorrentManager already connected')
開發者ID:brussee,項目名稱:tsap,代碼行數:27,代碼來源:TorrentManager.py

示例6: __init__

 def __init__(self,guiUtility):
     if TorrentManager.__single:
         raise RuntimeError, "TorrentSearchGridManager is singleton"
     TorrentManager.__single = self
     self.guiUtility = guiUtility
     
     # Contains all matches for keywords in DB, not filtered by category
     self.hits = []
     
     # Remote results for current keywords
     self.remoteHits = {}
     
     # For asking for a refresh when remote results came in
     self.gridmgr = None
     self.guiserver = GUITaskQueue.getInstance()
     
     self.searchkeywords = []
     self.rerankingStrategy = DefaultTorrentReranker()
     self.oldsearchkeywords = []
     
     self.filteredResults = 0
     
     self.bundler = Bundler()
     self.bundle_mode = None
     self.category = Category.getInstance()
開發者ID:csko,項目名稱:Tribler,代碼行數:25,代碼來源:SearchGridManager.py

示例7: db_callback

        def db_callback():
            familyfilter_sql = Category.getInstance().get_family_filter_sql(self.torrentdb._getCategoryID)
            if familyfilter_sql:
                familyfilter_sql = familyfilter_sql[4:]

            topTen = self.torrentdb._db.getAll("CollectedTorrent", ("infohash", "name", "(num_seeders+num_leechers) as popularity"), where = familyfilter_sql , order_by = "(num_seeders+num_leechers) DESC", limit= 10)
            self._RefreshList(topTen)
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:7,代碼來源:home.py

示例8: toggleFamilyFilter

 def toggleFamilyFilter(self, state = None):
      catobj = Category.getInstance()
      ff_enabled = not catobj.family_filter_enabled()
      #print 'Setting family filter to: %s' % ff_enabled
      if state is not None:
          ff_enabled = state
      catobj.set_family_filter(ff_enabled)
開發者ID:egbertbouman,項目名稱:tribler-g,代碼行數:7,代碼來源:GuiUtility.py

示例9: testFilter

def testFilter(catfilename, torrentpath):    
    readCategorisationFile(catfilename)
    #print 'Install_dir is %s' % execpath
    c = Category.getInstance(execpath, None)
    total = porn = fn = fp = 0
    for tfilename,isporn in tdict.items():
        torrent = getMetainfo(os.path.join(torrentpath,tfilename))
        name = torrent['info']['name']
        cat = c.calculateCategory(torrent, name)
        fporn = (cat == ['xxx'])
        total+= 1
        porn += int(isporn)
        if isporn == fporn:
            if DEBUG:
                print (isporn, fporn), 'good', name
            
        elif isporn and not fporn:
            fn+=1
            print 'FALSE NEGATIVE'
            showTorrent(os.path.join(torrentpath,tfilename))
        elif not isporn and fporn:
            fp +=1
            print 'FALSE POSITIVE'
            showTorrent(os.path.join(torrentpath,tfilename))
            
    print """
    Total torrents:   %(total)d
    XXX torrents:     %(porn)d
    Correct filtered: %(good)d
    False negatives:  %(fn)d
    False positives:  %(fp)d
    """ % {'total':total, 'porn':porn, 'fn':fn,'fp':fp,'good':total-fn-fp}
開發者ID:egbertbouman,項目名稱:tribler-g,代碼行數:32,代碼來源:TestCategory.py

示例10: __init__

    def __init__(self,guiUtility):
        if TorrentManager.__single:
            raise RuntimeError, "TorrentSearchGridManager is singleton"
        TorrentManager.__single = self
        self.guiUtility = guiUtility
        
        # Contains all matches for keywords in DB, not filtered by category
        self.hits = []
        
        # Remote results for current keywords
        self.remoteHits = {}
        
        #current progress of download states
        self.cache_progress = {}
        
        # For asking for a refresh when remote results came in
        self.gridmgr = None
        self.guiserver = GUITaskQueue.getInstance()
        
        # Gui callbacks
        self.gui_callback = []

        self.searchkeywords = {'filesMode':[], 'libraryMode':[]}
        self.rerankingStrategy = {'filesMode':DefaultTorrentReranker(), 'libraryMode':DefaultTorrentReranker()}
        self.oldsearchkeywords = {'filesMode':[], 'libraryMode':[]} # previous query
        
        self.filteredResults = 0
        self.category = Category.getInstance()
        
        # 09/10/09 boudewijn: CallLater does not accept zero as a
        # delay. the value needs to be a positive integer.
        self.user_download_choice = UserDownloadChoice.get_singleton()
開發者ID:egbertbouman,項目名稱:tribler-g,代碼行數:32,代碼來源:SearchGridManager.py

示例11: __init__

    def __init__(self):
        self.session = FakeSession()
        self.crawler = Crawler.get_instance(self.session)

        self.my_db          = MyDBHandler.getInstance()
        self.peer_db        = PeerDBHandler.getInstance()
        self.torrent_db     = TorrentDBHandler.getInstance()
        self.torrent_db.register(Category.getInstance(),'.')
        self.mypref_db      = MyPreferenceDBHandler.getInstance()
        self.pref_db        = PreferenceDBHandler.getInstance()
        self.superpeer_db   = SuperPeerDBHandler.getInstance()
        self.friend_db      = FriendDBHandler.getInstance()
        self.bartercast_db  = BarterCastDBHandler.getInstance()
        self.bartercast_db.registerSession(self.session)
        self.secure_overlay = FakeSecureOverlay()
#        torrent_collecting_dir = os.path.abspath(config['torrent_collecting_dir'])
        self.listen_port = 1234

        self.channelcast_db = ChannelCastDBHandler.getInstance()
        self.channelcast_db.registerSession(self.session)

        self.votecast_db = VoteCastDBHandler.getInstance()
        self.votecast_db.registerSession(self.session)
        self.simi_db        = SimilarityDBHandler.getInstance()
        self.pops_db = PopularityDBHandler.getInstance()
開發者ID:Devristo,項目名稱:tribler,代碼行數:25,代碼來源:test_buddycast2_datahandler.py

示例12: toggleFamilyFilter

    def toggleFamilyFilter(self, newState=None, setCheck=False):
        if newState is None:
            newState = not self.getFamilyFilter()

        Category.getInstance().set_family_filter(newState)
        for l in self.lists:
            if getattr(l, 'GotFilter', False):
                l.GotFilter(None)

        if setCheck:
            self.frame.SRstatusbar.ff_checkbox.SetValue(newState)

        self.frame.home.aw_panel.refreshNow()

        if newState:
            self.utility.write_config('family_filter', 1)
        else:
            self.utility.write_config('family_filter', 0)
        self.utility.flush_config()
開發者ID:Antiade,項目名稱:tribler,代碼行數:19,代碼來源:GuiUtility.py

示例13: init

def init():
    init_bak_tribler_sdb()

    db = SQLiteCacheDB.getInstance()
    db.initDB(TRIBLER_DB_PATH, busytimeout=BUSYTIMEOUT)

    print >>sys.stderr,"OPENING DB",TRIBLER_DB_PATH

    #db.execute_write('drop index Torrent_relevance_idx')
    TorrentDBHandler.getInstance().register(Category.getInstance('..'),'.')
開發者ID:Devristo,項目名稱:tribler,代碼行數:10,代碼來源:test_buddycast2_datahandler.py

示例14: setUp

    def setUp(self):
        super(TestTorrentDBHandler, self).setUp()

        from Tribler.Core.APIImplementation.LaunchManyCore import TriblerLaunchMany
        from Tribler.Core.Modules.tracker_manager import TrackerManager
        self.session.lm = TriblerLaunchMany()
        self.session.lm.tracker_manager = TrackerManager(self.session)
        self.session.lm.tracker_manager.initialize()
        self.tdb = TorrentDBHandler(self.session)
        self.tdb.torrent_dir = TESTS_DATA_DIR
        self.tdb.category = Category.getInstance(self.session)
        self.tdb.mypref_db = MyPreferenceDBHandler(self.session)
開發者ID:Antiade,項目名稱:tribler,代碼行數:12,代碼來源:test_sqlitecachedbhandler.py

示例15: reimport_torrents

    def reimport_torrents(self):
        """Import all torrent files in the collected torrent dir, all the files already in the database will be ignored.
        """
        self.status_update_func("Opening TorrentDBHandler...")
        # TODO(emilon): That's a freakishly ugly hack.
        torrent_db_handler = TorrentDBHandler(self.session)
        torrent_db_handler.category = Category.getInstance(self.session)

        # TODO(emilon): It would be nice to drop the corrupted torrent data from the store as a bonus.
        self.status_update_func("Registering recovered torrents...")
        try:
            for infoshash_str, torrent_data in self.torrent_store.itervalues():
                self.status_update_func("> %s" % infoshash_str)
                torrentdef = TorrentDef.load_from_memory(torrent_data)
                if torrentdef.is_finalized():
                    infohash = torrentdef.get_infohash()
                    if not torrent_db_handler.hasTorrent(infohash):
                        self.status_update_func(u"Registering recovered torrent: %s" % hexlify(infohash))
                        torrent_db_handler._addTorrentToDB(torrentdef, extra_info={"filename": infoshash_str})
        finally:
            torrent_db_handler.close()
            Category.delInstance()
            self.db.commit_now()
            return self.torrent_store.flush()
開發者ID:Antiade,項目名稱:tribler,代碼行數:24,代碼來源:db_upgrader.py


注:本文中的Tribler.Category.Category.Category類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。