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


Python Archive.list_archives方法代码示例

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


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

示例1: do_list

# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import list_archives [as 别名]
 def do_list(self, args):
     """List archive or repository contents"""
     repository = self.open_repository(args.src)
     manifest, key = Manifest.load(repository)
     if args.src.archive:
         tmap = {1: 'p', 2: 'c', 4: 'd', 6: 'b', 0o10: '-', 0o12: 'l', 0o14: 's'}
         archive = Archive(repository, key, manifest, args.src.archive)
         for item in archive.iter_items():
             type = tmap.get(item[b'mode'] // 4096, '?')
             mode = format_file_mode(item[b'mode'])
             size = 0
             if type == '-':
                 try:
                     size = sum(size for _, size, _ in item[b'chunks'])
                 except KeyError:
                     pass
             mtime = format_time(datetime.fromtimestamp(bigint_to_int(item[b'mtime']) / 1e9))
             if b'source' in item:
                 if type == 'l':
                     extra = ' -> %s' % item[b'source']
                 else:
                     type = 'h'
                     extra = ' link to %s' % item[b'source']
             else:
                 extra = ''
             print('%s%s %-6s %-6s %8d %s %s%s' % (type, mode, item[b'user'] or item[b'uid'],
                                               item[b'group'] or item[b'gid'], size, mtime,
                                               remove_surrogates(item[b'path']), extra))
     else:
         for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):
             print(format_archive(archive))
     return self.exit_code
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-attic,代码行数:34,代码来源:archiver.py

示例2: do_prune

# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import list_archives [as 别名]
    def do_prune(self, args):
        """Prune repository archives according to specified rules
        """
        repository = self.open_repository(args.repository)
        manifest, key = Manifest.load(repository)
        cache = Cache(repository, key, manifest)
        archives = list(sorted(Archive.list_archives(repository, key, manifest, cache),
                               key=attrgetter('ts'), reverse=True))
        if args.hourly + args.daily + args.weekly + args.monthly + args.yearly == 0:
            self.print_error('At least one of the "hourly", "daily", "weekly", "monthly" or "yearly" '
                             'settings must be specified')
            return 1
        if args.prefix:
            archives = [archive for archive in archives if archive.name.startswith(args.prefix)]
        keep = []
        if args.hourly:
            keep += prune_split(archives, '%Y-%m-%d %H', args.hourly)
        if args.daily:
            keep += prune_split(archives, '%Y-%m-%d', args.daily, keep)
        if args.weekly:
            keep += prune_split(archives, '%G-%V', args.weekly, keep)
        if args.monthly:
            keep += prune_split(archives, '%Y-%m', args.monthly, keep)
        if args.yearly:
            keep += prune_split(archives, '%Y', args.yearly, keep)

        keep.sort(key=attrgetter('ts'), reverse=True)
        to_delete = [a for a in archives if a not in keep]

        for archive in keep:
            self.print_verbose('Keeping archive "%s"' % archive.name)
        for archive in to_delete:
            self.print_verbose('Pruning archive "%s"', archive.name)
            archive.delete(cache)
        return self.exit_code
开发者ID:Ernest0x,项目名称:attic,代码行数:37,代码来源:archiver.py

示例3: do_prune

# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import list_archives [as 别名]
    def do_prune(self, args):
        """Prune repository archives according to specified rules
        """
        repository = self.open_repository(args.repository)
        manifest, key = Manifest.load(repository)
        cache = Cache(repository, key, manifest)
        archives = list(sorted(Archive.list_archives(repository, key, manifest, cache),
                               key=attrgetter('ts'), reverse=True))
        if args.hourly + args.daily + args.weekly + args.monthly + args.yearly == 0 and args.within is None:
            self.print_error('At least one of the "within", "hourly", "daily", "weekly", "monthly" or "yearly" '
                             'settings must be specified')
            return 1
        if args.prefix:
            archives = [archive for archive in archives if archive.name.startswith(args.prefix)]
        keep = []
        if args.within:
            keep += prune_within(archives, args.within)
        if args.hourly:
            keep += prune_split(archives, '%Y-%m-%d %H', args.hourly, keep)
        if args.daily:
            keep += prune_split(archives, '%Y-%m-%d', args.daily, keep)
        if args.weekly:
            keep += prune_split(archives, '%G-%V', args.weekly, keep)
        if args.monthly:
            keep += prune_split(archives, '%Y-%m', args.monthly, keep)
        if args.yearly:
            keep += prune_split(archives, '%Y', args.yearly, keep)

        keep.sort(key=attrgetter('ts'), reverse=True)
        to_delete = [a for a in archives if a not in keep]
        stats = Statistics()
        for archive in keep:
            self.print_verbose('Keeping archive: %s' % format_archive(archive))
        for archive in to_delete:
            if args.dry_run:
                self.print_verbose('Would prune:     %s' % format_archive(archive))
            else:
                self.print_verbose('Pruning archive: %s' % format_archive(archive))
                archive.delete(stats)
        if to_delete and not args.dry_run:
            manifest.write()
            repository.commit()
            cache.commit()
        if args.stats:
            stats.print_('Deleted data:', cache)
        return self.exit_code
开发者ID:iceqapprentice,项目名称:attic,代码行数:48,代码来源:archiver.py

示例4: do_delete

# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import list_archives [as 别名]
 def do_delete(self, args):
     """Delete an existing repository or archive"""
     repository = self.open_repository(args.target, exclusive=True)
     manifest, key = Manifest.load(repository)
     cache = Cache(repository, key, manifest, do_files=args.cache_files)
     if args.target.archive:
         archive = Archive(repository, key, manifest, args.target.archive, cache=cache)
         stats = Statistics()
         archive.delete(stats)
         manifest.write()
         repository.commit()
         cache.commit()
         if args.stats:
             stats.print_('Deleted data:', cache)
     else:
         print("You requested to completely DELETE the repository *including* all archives it contains:")
         for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):
             print(format_archive(archive))
         print("""Type "YES" if you understand this and want to continue.\n""")
         if input('Do you want to continue? ') == 'YES':
             repository.destroy()
             cache.destroy()
             print("Repository and corresponding cache were deleted.")
     return self.exit_code
开发者ID:joolswills,项目名称:borg,代码行数:26,代码来源:archiver.py


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