コード例 #1
0
ファイル: dbsqlite.py プロジェクト: rafiyr/gpodder
    def podcast_download_folder_exists(self, foldername):
        """
        Returns True if a foldername for a channel exists.
        False otherwise.
        """
        foldername = util.convert_bytes(foldername)

        return self.get("SELECT id FROM %s WHERE download_folder = ?" % self.TABLE_PODCAST, (foldername,)) is not None
コード例 #2
0
ファイル: dbsqlite.py プロジェクト: drmrboy/gpodder
    def episode_filename_exists(self, podcast_id, filename):
        """
        Returns True if a filename for an episode exists.
        False otherwise.
        """
        filename = util.convert_bytes(filename)

        return self.get("SELECT id FROM %s WHERE podcast_id = ? AND download_filename = ?" %
                self.TABLE_EPISODE, (podcast_id, filename,)) is not None
コード例 #3
0
ファイル: dbsqlite.py プロジェクト: samusz/gpodder
    def podcast_download_folder_exists(self, foldername):
        """
        Returns True if a foldername for a channel exists.
        False otherwise.
        """
        foldername = util.convert_bytes(foldername)

        return self.get("SELECT id FROM %s WHERE download_folder = ?" %
                self.TABLE_PODCAST, (foldername,)) is not None
コード例 #4
0
ファイル: dbsqlite.py プロジェクト: samusz/gpodder
    def episode_filename_exists(self, podcast_id, filename):
        """
        Returns True if a filename for an episode exists.
        False otherwise.
        """
        filename = util.convert_bytes(filename)

        return self.get("SELECT id FROM %s WHERE podcast_id = ? AND download_filename = ?" %
                self.TABLE_EPISODE, (podcast_id, filename,)) is not None
コード例 #5
0
ファイル: dbsqlite.py プロジェクト: rafiyr/gpodder
    def delete_episode_by_guid(self, guid, podcast_id):
        """
        Deletes episodes that have a specific GUID for
        a given channel. Used after feed updates for
        episodes that have disappeared from the feed.
        """
        guid = util.convert_bytes(guid)

        with self.lock:
            cur = self.cursor()
            cur.execute("DELETE FROM %s WHERE podcast_id = ? AND guid = ?" % self.TABLE_EPISODE, (podcast_id, guid))
コード例 #6
0
ファイル: dbsqlite.py プロジェクト: samusz/gpodder
    def delete_episode_by_guid(self, guid, podcast_id):
        """
        Deletes episodes that have a specific GUID for
        a given channel. Used after feed updates for
        episodes that have disappeared from the feed.
        """
        guid = util.convert_bytes(guid)

        with self.lock:
            cur = self.cursor()
            cur.execute('DELETE FROM %s WHERE podcast_id = ? AND guid = ?' %
                    self.TABLE_EPISODE, (podcast_id, guid))
コード例 #7
0
ファイル: model.py プロジェクト: obris/gpodder
    def one_line_description(self):
        MAX_LINE_LENGTH = 120
        desc = util.remove_html_tags(self.description or '')
        desc = re.sub('\s+', ' ', desc).strip()
        if not desc:
            return _('No description available')
        else:
            # Decode the description to avoid gPodder bug 1277
            desc = util.convert_bytes(desc).strip()

            if len(desc) > MAX_LINE_LENGTH:
                return desc[:MAX_LINE_LENGTH] + '...'
            else:
                return desc
コード例 #8
0
ファイル: model.py プロジェクト: wwweslei/gpodder
    def one_line_description(self):
        MAX_LINE_LENGTH = 120
        desc = util.remove_html_tags(self.description or '')
        desc = re.sub('\s+', ' ', desc).strip()
        if not desc:
            return _('No description available')
        else:
            # Decode the description to avoid gPodder bug 1277
            desc = util.convert_bytes(desc).strip()

            if len(desc) > MAX_LINE_LENGTH:
                return desc[:MAX_LINE_LENGTH] + '...'
            else:
                return desc
コード例 #9
0
ファイル: model.py プロジェクト: gpodder/gpodder
    def one_line_description(self):
        MAX_LINE_LENGTH = 120
        desc = util.remove_html_tags(self.description or "")
        desc = re.sub("\s+", " ", desc).strip()
        if not desc:
            return _("No description available")
        else:
            # Decode the description to avoid gPodder bug 1277
            desc = util.convert_bytes(desc).strip()

            if len(desc) > MAX_LINE_LENGTH:
                return desc[:MAX_LINE_LENGTH] + "..."
            else:
                return desc
コード例 #10
0
ファイル: dbsqlite.py プロジェクト: rafiyr/gpodder
    def _save_object(self, o, table, columns):
        with self.lock:
            try:
                cur = self.cursor()
                values = [util.convert_bytes(getattr(o, name)) for name in columns]

                if o.id is None:
                    qmarks = ", ".join("?" * len(columns))
                    sql = "INSERT INTO %s (%s) VALUES (%s)" % (table, ", ".join(columns), qmarks)
                    cur.execute(sql, values)
                    o.id = cur.lastrowid
                else:
                    qmarks = ", ".join("%s = ?" % name for name in columns)
                    values.append(o.id)
                    sql = "UPDATE %s SET %s WHERE id = ?" % (table, qmarks)
                    cur.execute(sql, values)
            except Exception, e:
                logger.error("Cannot save %s: %s", o, e, exc_info=True)

            cur.close()
コード例 #11
0
ファイル: dbsqlite.py プロジェクト: samusz/gpodder
    def _save_object(self, o, table, columns):
        with self.lock:
            try:
                cur = self.cursor()
                values = [util.convert_bytes(getattr(o, name))
                        for name in columns]

                if o.id is None:
                    qmarks = ', '.join('?'*len(columns))
                    sql = 'INSERT INTO %s (%s) VALUES (%s)' % (table, ', '.join(columns), qmarks)
                    cur.execute(sql, values)
                    o.id = cur.lastrowid
                else:
                    qmarks = ', '.join('%s = ?' % name for name in columns)
                    values.append(o.id)
                    sql = 'UPDATE %s SET %s WHERE id = ?' % (table, qmarks)
                    cur.execute(sql, values)
            except Exception as e:
                logger.error('Cannot save %s: %s', o, e, exc_info=True)

            cur.close()
コード例 #12
0
ファイル: episodeselector.py プロジェクト: Nvlawachan/gpodder
    def treeview_episodes_query_tooltip(self, treeview, x, y, keyboard_tooltip,
                                        tooltip):
        # With get_bin_window, we get the window that contains the rows without
        # the header. The Y coordinate of this window will be the height of the
        # treeview header. This is the amount we have to subtract from the
        # event's Y coordinate to get the coordinate to pass to get_path_at_pos
        (x_bin, y_bin) = treeview.get_bin_window().get_position()
        y -= x_bin
        y -= y_bin
        (path, column, rx, ry) = treeview.get_path_at_pos(x, y) or (None, ) * 4

        if not self.episode_list_can_tooltip or column != treeview.get_columns(
        )[1]:
            self.last_tooltip_episode = None
            return False

        if path is not None:
            model = treeview.get_model()
            iter = model.get_iter(path)
            index = model.get_value(iter, self.COLUMN_INDEX)
            description = model.get_value(iter, self.COLUMN_TOOLTIP)
            if self.last_tooltip_episode is not None and self.last_tooltip_episode != index:
                self.last_tooltip_episode = None
                return False
            self.last_tooltip_episode = index

            description = util.remove_html_tags(description)
            # Bug 1825: make sure description is a unicode string,
            # so it may be cut correctly on UTF-8 char boundaries
            description = util.convert_bytes(description)
            if description is not None:
                if len(description) > 400:
                    description = description[:398] + '[...]'
                tooltip.set_text(description)
                return True
            else:
                return False

        self.last_tooltip_episode = None
        return False
コード例 #13
0
ファイル: episodeselector.py プロジェクト: Vegasq/gpodder
    def treeview_episodes_query_tooltip(self, treeview, x, y, keyboard_tooltip, tooltip):
        # With get_bin_window, we get the window that contains the rows without
        # the header. The Y coordinate of this window will be the height of the
        # treeview header. This is the amount we have to subtract from the
        # event's Y coordinate to get the coordinate to pass to get_path_at_pos
        (x_bin, y_bin) = treeview.get_bin_window().get_position()
        y -= x_bin
        y -= y_bin
        (path, column, rx, ry) = treeview.get_path_at_pos(x, y) or (None,)*4

        if not self.episode_list_can_tooltip or column != treeview.get_columns()[1]:
            self.last_tooltip_episode = None
            return False

        if path is not None:
            model = treeview.get_model()
            iter = model.get_iter(path)
            index = model.get_value(iter, self.COLUMN_INDEX)
            description = model.get_value(iter, self.COLUMN_TOOLTIP)
            if self.last_tooltip_episode is not None and self.last_tooltip_episode != index:
                self.last_tooltip_episode = None
                return False
            self.last_tooltip_episode = index

            description = util.remove_html_tags(description)
            # Bug 1825: make sure description is a unicode string,
            # so it may be cut correctly on UTF-8 char boundaries
            description = util.convert_bytes(description)
            if description is not None:
                if len(description) > 400:
                    description = description[:398]+'[...]'
                tooltip.set_text(description)
                return True
            else:
                return False

        self.last_tooltip_episode = None
        return False
コード例 #14
0
ファイル: __init__.py プロジェクト: obris/gpodder
 def getCopyright(self):
     return util.convert_bytes(gpodder.__copyright__)
コード例 #15
0
ファイル: __init__.py プロジェクト: obris/gpodder
 def getCredits(self):
     credits_file = os.path.join(gpodder.prefix, 'share', 'gpodder', 'credits.txt')
     return util.convert_bytes(open(credits_file).read())
コード例 #16
0
ファイル: helper.py プロジェクト: stefankoegl/gpodder
    def __init__(self, caption, action, target=None):
        QtCore.QObject.__init__(self)
        self._caption = util.convert_bytes(caption)

        self.action = action
        self.target = target
コード例 #17
0
 def getCopyright(self):
     return util.convert_bytes(gpodder.__copyright__)
コード例 #18
0
 def getCredits(self):
     credits_file = os.path.join(gpodder.prefix, 'share', 'gpodder',
                                 'credits.txt')
     return util.convert_bytes(open(credits_file).read())
コード例 #19
0
ファイル: helper.py プロジェクト: Dragontek/gpodder
    def __init__(self, caption, action, target=None):
        QtCore.QObject.__init__(self)
        self._caption = util.convert_bytes(caption)

        self.action = action
        self.target = target
コード例 #20
0
ファイル: model.py プロジェクト: wwweslei/gpodder
 def sort_key(cls, podcast):
     key = util.convert_bytes(podcast.title.lower())
     return re.sub('^the ', '', key).translate(cls.UNICODE_TRANSLATE)
コード例 #21
0
ファイル: model.py プロジェクト: gpodder/gpodder
 def sort_key(cls, podcast):
     key = util.convert_bytes(podcast.title.lower())
     return re.sub("^the ", "", key).translate(cls.UNICODE_TRANSLATE)
コード例 #22
0
ファイル: __init__.py プロジェクト: Dragontek/gpodder
 def getCredits(self):
     credits_file = os.path.join(gpodder.prefix, "share", "gpodder", "credits.txt")
     return util.convert_bytes(open(credits_file).read())