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


Python Utils.to_human_time方法代码示例

本文整理汇总了Python中Utils.Utils.to_human_time方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.to_human_time方法的具体用法?Python Utils.to_human_time怎么用?Python Utils.to_human_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.Utils的用法示例。


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

示例1: onAblumClick

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import to_human_time [as 别名]
    def onAblumClick(self, item):
        albums = self.ui.albumsTableWidget
        pics = self.ui.picturesTableWidget
        if item.checkState() == QtCore.Qt.Checked:
            print ('"%s" Checked' % item.text())
            album = item.text()
            self.notificate("Checking album (%s)" % (album), 1000)

            aid = albums.item(item.row(), 4).text()  # aid column == 4
            uid = str(self.settings["target"]).rsplit("/", 1)[-1].replace("id", "")

            pictures = self.vk_wrapper.get_album(str(aid), str(uid))

            def get_src(pic):
                for key in ("src_xxxbig", "src_xxbig", "src_xbig", "src_big", "src"):
                    if pic.has_key(key):
                        return pic[key]

            for pic in pictures:
                pics.setRowCount(pics.rowCount() + 1)
                row = pics.rowCount() - 1
                attrs = map(
                    lambda x: QtGui.QTableWidgetItem(x),
                    [get_src(pic), _fromUtf8(album), Utils.to_human_time(pic["created"]), str(pic["owner_id"])],
                )
                src = attrs[0]
                src.setFlags(
                    QtCore.Qt.ItemIsUserCheckable
                    | QtCore.Qt.ItemIsSelectable
                    | QtCore.Qt.ItemIsEditable
                    | QtCore.Qt.ItemIsEnabled
                )
                src.setCheckState(QtCore.Qt.Unchecked)

                [pics.setItem(row, i, attr) for (i, attr) in enumerate(attrs)]

                progressBar = QtGui.QProgressBar()
                progressBar.setProperty("value", 0)
                progressBar.setInvertedAppearance(False)
                pics.setCellWidget(row, len(attrs), progressBar)

        else:
            print ('"%s" Clicked' % item.text())
            removed_album = str(item.text())
            removed_rows = []
            for row in range(pics.rowCount()):
                if str(pics.item(row, 1).text()) == removed_album:
                    removed_rows.append(row)
            for row in sorted(removed_rows, reverse=True):
                pics.removeRow(row)
            is_removed_album = lambda x: str(x["album"]) != removed_album
            self.download_list = filter(is_removed_album, self.download_list)
            self.window.repaint()
开发者ID:herbion,项目名称:vk-photos,代码行数:55,代码来源:VkCrawler.py

示例2: scanForAlbums

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import to_human_time [as 别名]
    def scanForAlbums(self):
        self.notificate("Started albums scanning ...", 2000)
        self._auth()
        # self.ui.picturesTableWidget.clearContent() ###
        albums = None

        if not self.settings.has_key("target"):
            self.notificate("Target not setted, scanning own directory ...")
            albums = self.vk_wrapper.get_albums()
        else:
            uid = str(self.settings["target"]).rsplit("/", 1)[-1].replace("id", "")
            self.show_message("", "uid: " + uid)
            albums = self.vk_wrapper.get_albums(uid)

        table = self.ui.albumsTableWidget
        self.ui.albumsTableWidget.setRowCount(len(albums))

        if len(albums) == 0:
            self.show_message("sorry", "there is no albums")

        for (row, album) in enumerate(albums):
            attrs = map(
                lambda x: QtGui.QTableWidgetItem(x),
                [
                    _fromUtf8(album["title"]),
                    str(album["size"]),
                    Utils.to_human_time(album["created"]),
                    Utils.to_human_time(album["updated"]),
                    album["aid"],
                ],
            )
            title = attrs[0]
            title.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
            title.setCheckState(QtCore.Qt.Unchecked)
            [table.setItem(row, i, attr) for (i, attr) in enumerate(attrs)]
        table.itemClicked.connect(self.onAblumClick)

        self.window.repaint()
        self.notificate("Fetched albums successfully", 2000)
开发者ID:herbion,项目名称:vk-photos,代码行数:41,代码来源:VkCrawler.py


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