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


Python imp.ImportPlugin类代码示例

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


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

示例1: clear

 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     if self.openfile:
         self.openfile.close()
         self.openfile = None
         self.fileversion = 0
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:7,代码来源:AMC.py

示例2: clear

 def clear(self):
     IP.clear(self)
     self.nb_pages.get_nth_page(1).hide()
     self.csv_header = None
     self.ls_assigned.clear()
     self.ls_griffith.clear()
     # add default griffith fields again
     self.set_griffith_fields()
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:8,代码来源:CSV.py

示例3: set_source

 def set_source(self, name):
     IP.set_source(self, name)
     self.filename = name
     self.fileversion = self.read_fileversion()
     if self.fileversion == None:
         gutils.error(_('The format of the file is not supported.'))
         return False
     return True
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:8,代码来源:AllMyMovies.py

示例4: clear

 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     if self.filedom:
         self.filedom.unlink()
         self.filedom = None
         self.fileversion = None
         self.items = None
         self.itemindex = 0
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:9,代码来源:DVDProfiler.py

示例5: clear

 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     if self.cursor:
         self.cursor.close()
         self.cursor = None
     if self.connection:
         self.connection.close()
         self.connection = None
     self.fileversion = None
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:10,代码来源:AllMyMovies.py

示例6: clear

 def clear(self):
     """clear plugin state before next source file"""
     IP.clear(self)
     if self.xml:
         self.xml = None
         self.fileversion = None
         self.items = None
         self.itemindex = 0
         if self.poster_file:
             os.unlink(self.poster_file)
             self.poster_file = None
开发者ID:pld-linux,项目名称:griffith,代码行数:11,代码来源:Kodi.py

示例7: set_source

 def set_source(self, name):
     IP.set_source(self, name)
     self.filename = name
     self.fileversion = self.read_fileversion()
     if self.fileversion == None:
         gutils.error(_('The format of the file is not supported.'))
         return False
     if self.filename:
         self.imdbfilename = os.path.join(os.path.dirname(self.filename), 'IMDb.dat')
     else:
         self.imdbfilename = None
     return True
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:12,代码来源:MovieTrack.py

示例8: initialize

    def initialize(self):
        if not IP.initialize(self):
            return False
        self.edit = False
        self.tempfiles = TempFileCleanup()

        # try requests cache if available
        try:
            import requests_cache
            requests_cache.install_cache('kodi_cache')
        except:
            pass

        return True
开发者ID:pld-linux,项目名称:griffith,代码行数:14,代码来源:Kodi.py

示例9: initialize

    def initialize(self):
        if not IP.initialize(self):
            return False
        # glade
        gf = os.path.join(self.locations['glade'], 'importcsv.glade')
        # try to open the glade file
        try:
            self.gtk = gtk.glade.XML(gf)
        except:
            log.info("Glade-file %s can not be loaded.", gf)
            return False
        # open gtk window
        self.gtk.get_widget('d_import').set_transient_for(self.widgets['window'])

        # simple string lists
        self.tv_csv = self.gtk.get_widget('tv_csv')
        self.tv_assigned = self.gtk.get_widget('tv_assigned')
        self.tv_griffith = self.gtk.get_widget('tv_griffith')

        # 1st list
        self.ls_csv = gtk.ListStore(str)
        self.tv_csv.set_model(self.ls_csv)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("none", renderer, text=0)
        self.tv_csv.append_column(column)

        # 2nd list
        self.ls_griffith = gtk.ListStore(str, str)
        self.tv_griffith.set_model(self.ls_griffith)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("none", renderer, text=0)
        column.set_visible(False)
        self.tv_griffith.append_column(column)
        column = gtk.TreeViewColumn("none", renderer, text=1)
        self.tv_griffith.append_column(column)
        self.set_griffith_fields()

        # 3rd list
        self.ls_assigned = gtk.ListStore(str, str, str)
        self.tv_assigned.set_model(self.ls_assigned)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("none", renderer, text=0)
        self.tv_assigned.append_column(column)
        # add the columns for internal information handling and hide them
        column = gtk.TreeViewColumn("none", renderer, text=1)
        column.set_visible(False)
        self.tv_assigned.append_column(column)
        column = gtk.TreeViewColumn("none", renderer, text=2)
        column.set_visible(False)
        self.tv_assigned.append_column(column)

        # hide tabs
        self.nb_pages = self.gtk.get_widget('nb_pages')
        self.nb_pages.get_nth_page(1).hide()
        self.nb_pages.connect("switch-page", self._on_page_changed)

        # Events
        # Buttons
        self.b_cancel = self.gtk.get_widget("b_cancel")
        self.b_cancel.connect("clicked", self._clicked)

        self.b_next = self.gtk.get_widget("b_next")
        self.b_next.connect("clicked", self._clicked)

        self.b_back = self.gtk.get_widget("b_back")
        self.b_back.connect("clicked", self._clicked)

        self.b_add = self.gtk.get_widget("b_add")
        self.b_add.connect("clicked", self._clicked)

        self.b_del = self.gtk.get_widget("b_del")
        self.b_del.connect("clicked", self._clicked)

        # Treeviews
        self.tv_griffith.connect("row_activated", self._on_row_activated)
        self.tv_griffith.connect("cursor_changed", self._on_cursor_changed)
        self.tv_csv.connect("row_activated", self._on_row_activated)
        self.tv_csv.connect("cursor_changed", self._on_cursor_changed)
        self.tv_assigned.connect("cursor_changed", self._on_cursor_changed)

        self.gtk.get_widget('e_lineterminator').set_active(0)

        self.selected_griffith = None
        self.selected_csv = None
        self.current_csv_row = 0
        self.csv_header = None
        return True
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:87,代码来源:CSV.py

示例10: initialize

 def initialize(self):
     if not IP.initialize(self):
         return False
     self.edit = False
     return True
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:5,代码来源:AllMyMovies.py

示例11: destroy

 def destroy(self):
     """close all resources"""
     IP.destroy(self)
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:3,代码来源:AllMyMovies.py

示例12: clear

 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     self.cursor = None
     self.connection = None
     self.fileversion = None
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:6,代码来源:WintoolzFilmdatenbank.py

示例13: set_source

    def set_source(self, name):
        # source _dependent_ initialization goes here
        if name is None or not os.path.isfile(name):
            return False
        IP.set_source(self, name)
        self.__source_name = name
        # auto-detect file-encoding (optional)
        try:
            from chardet.universaldetector import UniversalDetector

            detector = UniversalDetector()
            detector.reset()
            lines = 0
            for line in file(self.__source_name, "rb"):
                detector.feed(line)
                lines += 1
                if detector.done or lines == 50:
                    break
            detector.close()
            encoding = string.lower(detector.result["encoding"])
        except:
            log.exception("")
            encoding = "utf_8"
        encoding = self._encoding_cleanup.sub("", encoding)
        model = self.gtk.get_widget("e_encoding").get_model()
        itempos = 0
        for item in model:
            pos1 = string.find(self._encoding_cleanup.sub("", string.lower(str(item[0]))), encoding)
            if pos1 == 0:
                break
            itempos += 1
        self.gtk.get_widget("e_encoding").set_active(itempos)
        # auto-detect CSV import settings (optional)
        try:
            import csv

            sniffer = csv.Sniffer()
            csvfilesize = os.path.getsize(self.__source_name)
            if csvfilesize > 65535:
                csvfilesize = 65535
            csvfile = file(self.__source_name, "rb")
            try:
                # quote char, line terminator and field delimiter
                proposed_dialect = sniffer.sniff(csvfile.read(csvfilesize))
                self.gtk.get_widget("e_delimiter").set_text(proposed_dialect.delimiter)
                self.gtk.get_widget("e_quotechar").set_text(proposed_dialect.quotechar)
                if proposed_dialect.lineterminator == "\r\n":
                    self.gtk.get_widget("e_lineterminator").set_active(1)
                # first row with column headers
                csvfile.seek(0)
                if sniffer.has_header(csvfile.read(csvfilesize)):
                    self.gtk.get_widget("e_startrow").set_text("1")
                else:
                    self.gtk.get_widget("e_startrow").set_text("0")
            finally:
                csvfile.close()
        except:
            log.exception("")
        # run dialog
        response = self.gtk.get_widget("d_import").run()
        if response == gtk.RESPONSE_OK:
            return True
        else:
            return False
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:64,代码来源:CSV.py

示例14: destroy

 def destroy(self):
     """close all resources"""
     self.tempfiles = None
     IP.destroy(self)
开发者ID:pld-linux,项目名称:griffith,代码行数:4,代码来源:Kodi.py

示例15: destroy

 def destroy(self):
     """close all resources"""
     self.clear()
     IP.destroy(self)
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:4,代码来源:eXtremeMovieManager.py


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