Example #1
0
 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     if self.openfile:
         self.openfile.close()
         self.openfile = None
         self.fileversion = 0
Example #2
0
 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     if self.openedfile:
         self.openedfile.close()
         self.openedfile = None
     self.fileversion = None
Example #3
0
 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()
 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
Example #5
0
 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()
Example #6
0
 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
 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
Example #8
0
 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
Example #9
0
 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
 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
Example #11
0
 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
 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
Example #13
0
 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
Example #14
0
    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
Example #15
0
 def initialize(self):
     if not IP.initialize(self):
         return False
     self.edit = False
     return True
Example #16
0
 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
Example #17
0
    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
Example #18
0
 def destroy(self):
     """close all resources"""
     IP.destroy(self)
 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     self.cursor = None
     self.connection = None
     self.fileversion = None
Example #20
0
 def destroy(self):
     """close all resources"""
     self.clear()
     IP.destroy(self)
Example #21
0
 def clear(self):
     """clear plugin before next source file"""
     IP.clear(self)
     self.cursor = None
     self.connection = None
     self.fileversion = None
Example #22
0
 def destroy(self):
     """close all resources"""
     self.tempfiles = None
     IP.destroy(self)
Example #23
0
    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
 def initialize(self):
     if not IP.initialize(self):
         return False
     self.edit = False
     return True
 def destroy(self):
     """close all resources"""
     IP.destroy(self)
Example #26
0
    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
 def destroy(self):
     """close all resources"""
     self.clear()
     IP.destroy(self)