本文整理匯總了Python中Tribler.Category.Category.Category.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Python Category.getInstance方法的具體用法?Python Category.getInstance怎麽用?Python Category.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tribler.Category.Category.Category
的用法示例。
在下文中一共展示了Category.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_family_filter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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
示例2: toggleFamilyFilter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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)
示例3: __init__
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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)
示例4: get_family_filter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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()
示例5: _connect
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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')
示例6: __init__
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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()
示例7: db_callback
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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)
示例8: testFilter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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}
示例9: toggleFamilyFilter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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)
示例10: __init__
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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()
示例11: __init__
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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()
示例12: toggleFamilyFilter
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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()
示例13: init
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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('..'),'.')
示例14: setUp
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
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)
示例15: _connect
# 需要導入模塊: from Tribler.Category.Category import Category [as 別名]
# 或者: from Tribler.Category.Category.Category import getInstance [as 別名]
def _connect(self):
"""
Load database handles and Dispersy.
:return: Nothing.
"""
if not self._connected:
self._connected = True
self._remote_lock = threading.Lock()
self._torrent_db = self._session.open_dbhandler(NTFY_TORRENTS)
self._channelcast_db = self._session.open_dbhandler(NTFY_CHANNELCAST)
self._votecast_db = self._session.open_dbhandler(NTFY_VOTECAST)
self._category = Category.getInstance()
self._dispersy = self._session.lm.dispersy
else:
raise RuntimeError("TorrentManager already connected")