当前位置: 首页>>代码示例>>Python>>正文


Python plugins.makeChannelFilename函数代码示例

本文整理汇总了Python中supybot.plugins.makeChannelFilename函数的典型用法代码示例。如果您正苦于以下问题:Python makeChannelFilename函数的具体用法?Python makeChannelFilename怎么用?Python makeChannelFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了makeChannelFilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getDb

    def _getDb(self, channel):
        import sqlite3

        if channel in self.dbs:
            return self.dbs[channel]
        filename = plugins.makeChannelFilename(self.filename, channel)
        
        if os.path.exists(filename):
            db = sqlite3.connect(filename, check_same_thread=False)
            if sys.version_info[0] < 3:
                db.text_factory = str
            self.dbs[channel] = db
            return db
        db = sqlite3.connect(filename, check_same_thread=False)
        if sys.version_info[0] < 3:
            db.text_factory = str
        self.dbs[channel] = db
        cursor = db.cursor()
        cursor.execute("""CREATE TABLE factoids (
                          key TEXT PRIMARY KEY,
                          created_by INTEGER,
                          created_at TIMESTAMP,
                          modified_by INTEGER,
                          modified_at TIMESTAMP,
                          locked_at TIMESTAMP,
                          locked_by INTEGER,
                          last_requested_by TEXT,
                          last_requested_at TIMESTAMP,
                          fact TEXT,
                          requested_count INTEGER
                          )""")
        db.commit()
        return db
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:33,代码来源:plugin.py

示例2: _getDb

 def _getDb(self, channel):
     filename = plugins.makeChannelFilename(self.filename, channel)
     if filename in self.dbs:
         return self.dbs[filename]
     if os.path.exists(filename):
         db = sqlite3.connect(filename)
         db.text_factory = str
         self.dbs[filename] = db
         return db
     db = sqlite3.connect(filename)
     db.text_factory = str
     self.dbs[filename] = db
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE karma (
                       id INTEGER PRIMARY KEY,
                       name TEXT,
                       normalized TEXT UNIQUE ON CONFLICT IGNORE,
                       added INTEGER,
                       subtracted INTEGER
                       )""")
     db.commit()
     def p(s1, s2):
         return int(ircutils.nickEqual(s1, s2))
     db.create_function('nickeq', 2, p)
     return db
开发者ID:Criptomonedas,项目名称:supybot_fixes,代码行数:25,代码来源:plugin.py

示例3: _getDb

    def _getDb(self, channel):
        filename = plugins.makeChannelFilename(self.filename, channel)

        if filename in self.dbs:
            return self.dbs[filename]

        if os.path.exists(filename):
            db = sqlite3.connect(filename, check_same_thread=False)
            db.text_factory = str
            self.dbs[filename] = db
            return db

        db = sqlite3.connect(filename, check_same_thread=False)
        db.text_factory = str
        self.dbs[filename] = db

        cur = db.cursor()
        cur.execute("""CREATE VIRTUAL TABLE quotes USING fts4(
        text TEXT,
        nick TEXT,
        ts INTEGER
        )""")
        db.commit()

        return db
开发者ID:rostob,项目名称:Limnoria-plugins,代码行数:25,代码来源:plugin.py

示例4: _getDb

    def _getDb(self, channel):
        filename = plugins.makeChannelFilename(self.filename, channel)
        if filename in self.dbs:
            return self.dbs[filename]
        if os.path.exists(filename):
            db = sqlite3.connect(filename)
            db.text_factory = str
            self.dbs[filename] = db
            return db
        db = sqlite3.connect(filename)
        db.text_factory = str
        self.dbs[filename] = db
        cursor = db.cursor()
        cursor.execute(
            """CREATE TABLE alias (
                          id INTEGER PRIMARY KEY,
                          name TEXT,
                          normalized TEXT,
                          aliases TEXT
                          )"""
        )
        db.commit()

        def p(s1, s2):
            return int(ircutils.nickEqual(s1, s2))

        db.create_function("nickeq", 2, p)
        return db
开发者ID:jfoots,项目名称:ircbot1,代码行数:28,代码来源:plugin.py

示例5: _getDb

 def _getDb(self, channel):
     sqlite = plugins.importSqlite()
     filename = plugins.makeChannelFilename(self.filename, channel)
     def p(s1, s2):
         return int(ircutils.nickEqual(s1.encode('iso8859-1'),
                                       s2.encode('iso8859-1')))
     if filename in self.dbs:
         self.dbs[filename].create_function('nickeq', 2, p)
         return self.dbs[filename]
     if os.path.exists(filename):
         self.dbs[filename] = sqlite.connect(filename)
         self.dbs[filename].create_function('nickeq', 2, p)
         return self.dbs[filename]
     db = sqlite.connect(filename)
     self.dbs[filename] = db
     self.dbs[filename].create_function('nickeq', 2, p)
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE quotegrabs (
                       id INTEGER PRIMARY KEY,
                       nick TEXT,
                       hostmask TEXT,
                       added_by TEXT,
                       added_at TIMESTAMP,
                       quote TEXT
                       );""")
     db.commit()
     return db
开发者ID:nixon,项目名称:boombot,代码行数:27,代码来源:plugin.py

示例6: _getDb

 def _getDb(self, channel):
     try:
         import sqlite
     except ImportError:
         raise callbacks.Error, \
               'You need to have PySQLite installed to use this ' \
               'plugin.  Download it at <http://pysqlite.org/>'
     if channel in self.dbs:
         return self.dbs[channel]
     filename = plugins.makeChannelFilename(self.filename, channel)
     if os.path.exists(filename):
         self.dbs[channel] = sqlite.connect(filename)
         return self.dbs[channel]
     db = sqlite.connect(filename)
     self.dbs[channel] = db
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE factoids (
                       key TEXT PRIMARY KEY,
                       created_by INTEGER,
                       created_at TIMESTAMP,
                       modified_by INTEGER,
                       modified_at TIMESTAMP,
                       locked_at TIMESTAMP,
                       locked_by INTEGER,
                       last_requested_by TEXT,
                       last_requested_at TIMESTAMP,
                       fact TEXT,
                       requested_count INTEGER
                       )""")
     db.commit()
     return db
开发者ID:Kefkius,项目名称:mazabot,代码行数:31,代码来源:plugin.py

示例7: _handleUrl

    def _handleUrl(self,irc,channel,nick,url):
        # 1 lookup from the db
        scname='%s_%s'%(irc.network,channel)

        if not UrlReader.databases.has_key(scname):
            # new db
            dbpath=plugins.makeChannelFilename('%s.db'%scname ,'urldata')
            UrlReader.databases[scname]=bsddb.btopen(dbpath,'c')

        urldb = UrlReader.databases[scname]

        if urldb.has_key(url):
            poster,title=pickle.loads(urldb[url])
            msg='%s has already posted it: %s'%(poster,title)
            irc.reply(msg.encode('utf-8'))
        else:

            try:
                title=self._getTitle(url)
                if title != None:
                    urldb[url]=pickle.dumps([nick.decode('utf-8'),title])
                    urldb.sync()
                    irc.reply(title.encode('utf-8'))
            except:
                traceback.print_exc()
                irc.reply('No Title')
开发者ID:fivesheep,项目名称:supybot-plugins,代码行数:26,代码来源:plugin.py

示例8: _getDb

    def _getDb(self, channel, debug=False):
        if channel in self.dbs:
            return self.dbs[channel]

        try:
            import sqlalchemy as sql
            self.sql = sql
        except ImportError:
            raise callbacks.Error('You need to have SQLAlchemy installed to use this ' \
                    'plugin.  Download it at <http://www.sqlalchemy.org/>')

        filename = plugins.makeChannelFilename(self.filename, channel)
        engine = sql.create_engine(self.engine + filename, echo=debug)
        metadata = sql.MetaData()
        firsts = sql.Table('firsts', metadata,
                           sql.Column('id', sql.Integer, primary_key=True),
                           sql.Column('first', sql.Text, unique=True),
                           sql.Column('count', sql.Integer, default=1),
                          )
        lasts = sql.Table('lasts', metadata,
                          sql.Column('id', sql.Integer, primary_key=True),
                          sql.Column('last', sql.Text, unique=True),
                          sql.Column('count', sql.Integer, default=1),
                         )
        pairs = sql.Table('pairs', metadata,
                          sql.Column('id', sql.Integer, primary_key=True),
                          sql.Column('first', sql.Text, default=sql.null),
                          sql.Column('second', sql.Text, default=sql.null),
                          sql.Column('follow', sql.Text, default=sql.null),
                          sql.Column('count', sql.Integer, default=1),
                          sql.UniqueConstraint('first', 'second', 'follow'),
                         )
        metadata.create_all(engine)
        self.dbs[channel] = (engine, firsts, lasts, pairs)
        return self.dbs[channel]
开发者ID:BFCatalin,项目名称:plugins,代码行数:35,代码来源:plugin.py

示例9: _getDb

 def _getDb(self, channel):
     try:
         import sqlite
     except ImportError:
         raise callbacks.Error, 'You need to have PySQLite installed to ' \
                                'use QuoteGrabs.  Download it at ' \
                                '<http://pysqlite.org/>'
     filename = plugins.makeChannelFilename(self.filename, channel)
     def p(s1, s2):
         return int(ircutils.nickEqual(s1, s2))
     if filename in self.dbs:
         return self.dbs[filename]
     if os.path.exists(filename):
         self.dbs[filename] = sqlite.connect(filename,
                                             converters={'bool': bool})
         self.dbs[filename].create_function('nickeq', 2, p)
         return self.dbs[filename]
     db = sqlite.connect(filename, converters={'bool': bool})
     self.dbs[filename] = db
     self.dbs[filename].create_function('nickeq', 2, p)
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE quotegrabs (
                       id INTEGER PRIMARY KEY,
                       nick TEXT,
                       hostmask TEXT,
                       added_by TEXT,
                       added_at TIMESTAMP,
                       quote TEXT
                       );""")
     db.commit()
     return db
开发者ID:jreese,项目名称:supybot-plugins,代码行数:31,代码来源:plugin.py

示例10: _getLastEntry

 def _getLastEntry(self, channel):
     """fetche the json data from either a file stored from the
     last request (only 1 request per 15 minutes allowed) or
     makes a new request and stores the result in a file as well
     """
     filename = plugins.makeChannelFilename('bitcoin', channel)
     # if file older than 15 minutes -> new query
     if os.path.exists(filename) == True:
         delta = datetime.timedelta(minutes=15)
         statbuf = os.stat(filename)
         now = datetime.datetime.now()
         modtime = datetime.datetime.fromtimestamp(statbuf.st_mtime) 
         if (now - delta) > modtime:
             data = self._fetchJsonData()
             self._writeToFile(simplejson.dumps(data), filename)
             log.info('new data')
             return simplejson.dumps(data)
         else:
             data = self._readFromFile(filename)
             log.info('old data')
             return  simplejson.dumps(data)
     else:
         data = self._fetchJsonData()
         self._writeToFile(simplejson.dumps(data), filename)     
         log.info('create new file and new data')
         return data
开发者ID:IT-Syndikat,项目名称:its-supybot-plugins,代码行数:26,代码来源:plugin.py

示例11: _getDb

 def _getDb(self, channel):
     filename = plugins.makeChannelFilename(self.filename, channel)
     def p(s1, s2):
         # text_factory seems to only apply as an output adapter,
         # so doesn't apply to created functions; so we use str()
         return ircutils.nickEqual(str(s1), str(s2))
     if filename in self.dbs:
         return self.dbs[filename]
     if os.path.exists(filename):
         db = sqlite3.connect(filename)
         db.text_factory = str
         db.create_function('nickeq', 2, p)
         self.dbs[filename] = db
         return db
     db = sqlite3.connect(filename)
     db.text_factory = str
     db.create_function('nickeq', 2, p)
     self.dbs[filename] = db
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE quotegrabs (
                       id INTEGER PRIMARY KEY,
                       nick BLOB,
                       hostmask TEXT,
                       added_by TEXT,
                       added_at TIMESTAMP,
                       quote TEXT
                       );""")
     db.commit()
     return db
开发者ID:Athemis,项目名称:Limnoria,代码行数:29,代码来源:plugin.py

示例12: _getDb

 def _getDb(self, channel):
     try:
         import sqlite
     except ImportError:
         raise callbacks.Error, 'You need to have PySQLite installed to ' \
                                'use Poll.  Download it at ' \
                                '<http://pysqlite.org/>'
     filename = plugins.makeChannelFilename(self.filename, channel)
     if filename in self.dbs:
         return self.dbs[filename]
     if os.path.exists(filename):
         self.dbs[filename] = sqlite.connect(filename)
         return self.dbs[filename]
     db = sqlite.connect(filename)
     self.dbs[filename] = db
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE polls (
                       id INTEGER PRIMARY KEY,
                       question TEXT UNIQUE ON CONFLICT IGNORE,
                       started_by INTEGER,
                       open INTEGER)""")
     cursor.execute("""CREATE TABLE options (
                       id INTEGER,
                       poll_id INTEGER,
                       option TEXT,
                       UNIQUE (poll_id, id) ON CONFLICT IGNORE)""")
     cursor.execute("""CREATE TABLE votes (
                       user_id INTEGER,
                       poll_id INTEGER,
                       option_id INTEGER,
                       UNIQUE (user_id, poll_id)
                       ON CONFLICT IGNORE)""")
     db.commit()
     return db
开发者ID:Latinx,项目名称:supybot,代码行数:34,代码来源:plugin.py

示例13: _getDb

 def _getDb(self, channel):
     try:
         import sqlite
     except ImportError:
         raise callbacks.Error, 'You need to have PySQLite installed to ' \
                                'use Karma.  Download it at ' \
                                '<http://pysqlite.org/>'
     filename = plugins.makeChannelFilename(self.filename, channel)
     if filename in self.dbs:
         return self.dbs[filename]
     if os.path.exists(filename):
         self.dbs[filename] = sqlite.connect(filename)
         return self.dbs[filename]
     db = sqlite.connect(filename)
     self.dbs[filename] = db
     cursor = db.cursor()
     cursor.execute("""CREATE TABLE karma (
                       id INTEGER PRIMARY KEY,
                       name TEXT,
                       normalized TEXT UNIQUE ON CONFLICT IGNORE,
                       added INTEGER,
                       subtracted INTEGER
                       )""")
     db.commit()
     def p(s1, s2):
         return int(ircutils.nickEqual(s1, s2))
     db.create_function('nickeq', 2, p)
     return db
开发者ID:IT-Syndikat,项目名称:its-supybot-plugins,代码行数:28,代码来源:plugin.py

示例14: _getDb

 def _getDb(self, channel):
     if channel not in self.dbs:
         filename = plugins.makeChannelFilename(self.filename, channel)
         self.dbs[channel] = sqlite3.connect(filename)
         c = self.dbs[channel].execute("PRAGMA user_version")
         version = c.fetchone()[0]
         self._upgradeDb(self.dbs[channel], version)
     return self.dbs[channel]
开发者ID:tdfischer,项目名称:supybot-SignalGenerator,代码行数:8,代码来源:plugin.py

示例15: _getDb

 def _getDb(self, channel):
     import anydbm
     if channel not in self.dbs:
         filename = plugins.makeChannelFilename(self.filename, channel)
         # To keep the code simpler for addPair, I decided not to make
         # self.dbs[channel]['firsts'] and ['lasts'].  Instead, we'll pad
         # the words list being sent to addPair such that ['\n \n'] will be
         # ['firsts'] and ['\n'] will be ['lasts'].
         self.dbs[channel] = anydbm.open(filename, 'c')
     return self.dbs[channel]
开发者ID:furtherandsun,项目名称:Supybot-Markov,代码行数:10,代码来源:plugin.py


注:本文中的supybot.plugins.makeChannelFilename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。