• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pydoc.pager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: list_info

def list_info(args: object) -> int:
    """ List the info in the account or file.

    """

    filename = args.filename
    account = args.account

    # Read the accounts dictionary into accounts_dict.
    accounts_dict, _, master_key = read_file(filename)
    account_str = ''

    if account == 'ALL':
        # List all accounts.
        for account_data in accounts_dict.values():
            account_dict = crypt_to_dict(account_data, master_key)
            if account_dict:
                account_str += '\n' + dict_to_str(account_dict)
    else:
        # Get the sha512 hash of the account name.
        hashed_account = hash_name(account)

        account_data = accounts_dict.get(hashed_account, '')

        # If there was no account data exit.
        if not account_data:
            print("Account %s not found." % account)
            return 0

        account_str = dict_to_str(crypt_to_dict(account_data, master_key))

    import pydoc
    pydoc.pager(account_str)
开发者ID:zepto,项目名称:lessinfo,代码行数:33,代码来源:lessinfo.py


示例2: print_sorted_donor_list

 def print_sorted_donor_list(donor_objects, input_string):
     if input_string not in ("2", "13"):
         input_donor_data_pairs = {
             "1": "name",
             "3": "gender",
             "4": "dateofbirth",
             "5": "lastdonationdate",
             "6": "wassick",
             "7": "uniqueid",
             "8": "expofid",
             "9": "bloodtype",
             "10": "hemoglobin",
             "11": "emailaddress",
             "12": "mobilnumber",
         }
         list_to_print = sorted(donor_objects, key=attrgetter(input_donor_data_pairs[input_string]))
     elif input_string == "2":
         list_to_print = sorted(donor_objects, key=lambda x: int(x.weight))
     elif input_string == "13":
         list_to_print = sorted(donor_objects, key=lambda x: int(x.age))
     text = ""
     for don in list_to_print:
         text += "------------------------------\n"
         text += don.data_out() + "\n"
     text += "------------------------------\n"
     pydoc.pager(text)
     input("\n Press (ENTER) to go back")
     clear()
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:28,代码来源:donor_manager_csv.py


示例3: func

def func(parser, options, args):
    """Show commit log and diff
    """
    if options.applied:
        patches = crt_series.get_applied()
    elif options.unapplied:
        patches = crt_series.get_unapplied()
    elif len(args) == 0:
        patches = ['HEAD']
    elif '..' in ' '.join(args):
        # patch ranges
        applied = crt_series.get_applied()
        unapplied = crt_series.get_unapplied()
        patches = parse_patches(args, applied + unapplied + \
                                crt_series.get_hidden(), len(applied))
    else:
        # individual patches or commit ids
        patches = args

    if not options.stat:
        options.diff_flags.extend(color_diff_flags())
    commit_ids = [git_id(crt_series, patch) for patch in patches]
    commit_str = '\n'.join([git.pretty_commit(commit_id,
                                              flags = options.diff_flags)
                            for commit_id in commit_ids])
    if options.stat:
        commit_str = gitlib.diffstat(commit_str)
    if commit_str:
        pager(commit_str)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:29,代码来源:show.py


示例4: launch_program

    def launch_program(self):
        """launch the main program"""

        # Make pythia8
        print "Running make for pythia8 directory"
        misc.compile(cwd=os.path.join(self.running_dir, os.path.pardir), mode='cpp')
        if self.model_dir:
            print "Running make in %s" % self.model_dir
            misc.compile(cwd=self.model_dir, mode='cpp')
        # Finally run make for executable
        makefile = self.executable.replace("main_","Makefile_")
        print "Running make with %s" % makefile
        misc.compile(arg=['-f', makefile], cwd=self.running_dir, mode='cpp')
        
        print "Running " + self.executable
        
        output = open(os.path.join(self.running_dir, self.name), 'w')
        if not self.executable.startswith('./'):
            self.executable = os.path.join(".", self.executable)
        subprocess.call([self.executable], stdout = output, stderr = output,
                        cwd=self.running_dir)
        
        # Display the cross-section to the screen
        path = os.path.join(self.running_dir, self.name) 
        pydoc.pager(open(path).read())

        print "Output of the run is found at " + \
              os.path.realpath(os.path.join(self.running_dir, self.name))
开发者ID:cesarotti,项目名称:MMAPS,代码行数:28,代码来源:launch_ext_program.py


示例5: search_in_donors

    def search_in_donors():
        with open("Data/donors.csv", "r") as f:
            content = []
            for line in f:
                content.append(line.strip())
        del (content[0])
        if len(content) < 1:
            print("\n No entry found\n")
            input("\n Press (ENTER) to go back")
            clear()
            return None
        else:
            string_to_search = input("Search for donor: ")
            found_items = []
            for donor in content:
                if string_to_search.upper() in donor:
                    found_items.append(donor)
            donor_object_list = []
            for i in found_items:
                l = i.split(",")
                donor_object_list.append(Donor())
                donor_object_list[-1].name = l[0]
                donor_object_list[-1].weight = l[1]
                donor_object_list[-1].dateofbirth = l[3]
                donor_object_list[-1].emailaddress = l[-2]
                donor_object_list[-1].age = donor_object_list[-1].donor_age()
            szoveg = ""
            for i in donor_object_list:
                szoveg += "------------------------------\n"
                szoveg += i.data_out() + "\n"
            szoveg += "------------------------------\n"
            pydoc.pager(szoveg)

            input("\n Press (ENTER) to go back")
            clear()
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:35,代码来源:donor_manager_csv.py


示例6: _run

 def _run(self):
     withmeta = bool(self['meta'] or self['meta_like'])
     withuser = bool(self['user_id'] or self['user_name'])
     detail = self['detail'] or withmeta or withuser
     images = self.client.list_images(detail)
     images = self._filter_by_name(images)
     images = self._filter_by_id(images)
     if withuser:
         images = self._filter_by_user(images)
     if withmeta:
         images = self._filter_by_metadata(images)
     if self['detail'] and not (
             self['json_output'] or self['output_format']):
         images = self._add_name(self._add_name(images, 'tenant_id'))
     elif detail and not self['detail']:
         for img in images:
             for key in set(img).difference(self.PERMANENTS):
                 img.pop(key)
     kwargs = dict(with_enumeration=self['enum'])
     if self['limit']:
         images = images[:self['limit']]
     if self['more']:
         kwargs['out'] = StringIO()
         kwargs['title'] = ()
     self._print(images, **kwargs)
     if self['more']:
         pager(kwargs['out'].getvalue())
开发者ID:Erethon,项目名称:kamaki,代码行数:27,代码来源:image.py


示例7: func

def func(parser, options, args):
    """Show the tree diff
    """
    args = git.ls_files(args)
    directory.cd_to_topdir()

    if options.revs:
        rev_list = options.revs.split('..')
        rev_list_len = len(rev_list)
        if rev_list_len == 1:
            rev1 = rev_list[0]
            rev2 = None
        elif rev_list_len == 2:
            rev1 = rev_list[0]
            rev2 = rev_list[1]
        else:
            parser.error('incorrect parameters to -r')
    else:
        rev1 = 'HEAD'
        rev2 = None

    if not options.stat:
        options.diff_flags.extend(color_diff_flags())
    diff_str = git.diff(args, rev1 and git_id(crt_series, rev1),
                        rev2 and git_id(crt_series, rev2),
                        diff_flags = options.diff_flags)
    if options.stat:
        out.stdout_raw(gitlib.diffstat(diff_str) + '\n')
    else:
        if diff_str:
            pager(diff_str)
开发者ID:terinjokes,项目名称:stgit,代码行数:31,代码来源:diff.py


示例8: page_string

def page_string(str_to_page, pager_cmd):
    """
    Page str_to_page via the pager. Tries to do a bit of fail-safe checking. For
    example, if the command starts with less but less doesn't appear to be
    installed on the system, it will resort to the pydoc.pager method.
    """
    # By default, we expect the command to be `less -R`. If that is the
    # pager_cmd, but they don't have less on their machine, odds are they're
    # just using the default value. In this case the pager will fail, so we'll
    # just go via pydoc.pager, which tries to do smarter checking that we don't
    # want to bother trying to replicate.
    # import ipdb; ipdb.set_trace()
    use_fallback_page_function = False
    if pager_cmd is None:
        use_fallback_page_function = True
    elif pager_cmd == FLAG_FALLBACK:
        use_fallback_page_function = True
    elif pager_cmd.startswith('less'):
        # stealing this check from pydoc.getpager()
        if hasattr(os, 'system') and os.system('(less) 2>/dev/null') != 0:
            # no less!
            use_fallback_page_function = True

    if use_fallback_page_function:
        pydoc.pager(str_to_page)
    else:
        # Otherwise, obey the user.
        pydoc.pipepager(str_to_page, cmd=pager_cmd)
开发者ID:Ferdov,项目名称:eg,代码行数:28,代码来源:eg_util.py


示例9: _rest_pager

def _rest_pager(x):
    out = x[2]
    terminal_size = shutil.get_terminal_size(25).lines;
    if terminal_size <= len(out.split('\n')):
        pydoc.pager(out)
    else:
        print(out)
开发者ID:NaokiMiyata,项目名称:odenos,代码行数:7,代码来源:coroutine.py


示例10: uncaught_main

def uncaught_main():

    #parser.add_option("-f", "--file", dest="filename",
    #help="write report to FILE", metavar="FILE")
    #parser.add_option("-q", "--quiet",
    #action="store_false", dest="verbose", default=True,
    #help="don't print status messages to stdout")
    #parser.add_option

    num_args = len(sys.argv) - 1
    if num_args < 1 :
        writeln("No command specified. Try help")
        return

    cmd = to_unicode(sys.argv[1], input_encoding)
    if cmd == 'help':
        pydoc.pager(help_text)
        return

    p = MyPlan(cmd == 'reset')

    if cmd == 'reset': return # we don't need to do anything

    if cmd in ['change', 'fetch', 'follow', 'following', 
               'info', 'post', 'stdin', 'unfollow']:
        eval_cmd = u'p.{0}()'.format(cmd)
        eval(eval_cmd)
    else:
        writeln("Unrecognised command: " + cmd)
    return
开发者ID:blippy,项目名称:Thimbl-CLI,代码行数:30,代码来源:thimbl.py


示例11: main

def main():
  modules = find_glu_modules()

  out = StringIO()
  out.write('Welcome to GLU: The Genotype Library and Utilities\n')

  if not modules:
    out.write('\nNo modules found!\n')
    return

  # FIXME: Figure out what to do when width is too large
  width   = max(len(m[1]) for m in modules)+4

  inheading = None
  for heading,name,module in modules:
    if heading != inheading:
      inheading = heading
      out.write('\n%s:\n\n' % heading)

    abstract = getattr(module,'__abstract__','')

    initial_width = max(0,width-len(name)-4)
    text = textwrap.wrap(abstract, 78, initial_indent=' '*initial_width,
                                       subsequent_indent=' '*width)
    out.write('  %s  %s\n' % (name,'\n'.join(text)))

  pydoc.pager(out.getvalue())
开发者ID:gzhang-hli,项目名称:glu-genetics,代码行数:27,代码来源:list.py


示例12: print_genres

def print_genres():
  """
  Print a genre listing.

  Uses python's built-in paging mechanism to print a genre listing to the
  terminal.
  """
  genres = dict(filter(
    lambda x: type(x[1]) is unicode and x[1] != "<not-set>",
    eyed3.id3.genres.iteritems()))

  longest = len(max(genres.values(), key=len))

  # 3 for genre ID, 2*1 for spaces.
  genre_cols = term_size()[0] / (3 + 1 + 1 + longest)

  def pack_n(container, n):
    """
    Generator returning slices of n from container's elements.
    """
    idx = 0
    while idx < len(container)-n:
      yield container[idx:idx+n]
      idx += n
    yield container[idx:]

  pydoc.pager(
      "\n".join(
        [" ".join(x) for x in pack_n(
          ["{:3} {:{width}}".format(a[0], a[1], width=longest) for a in \
            genres.iteritems()],
          genre_cols)
          ]
        )
      )
开发者ID:the-isz,项目名称:cdrip,代码行数:35,代码来源:cdrip.py


示例13: func

def func(parser, options, args):
    """Show commit log and diff
    """
    applied = crt_series.get_applied()
    unapplied = crt_series.get_unapplied()

    if options.applied:
        patches = applied
    elif options.unapplied:
        patches = unapplied
    elif len(args) == 0:
        patches = ['HEAD']
    else:
        if len(args) == 1 and args[0].find('..') == -1 \
               and not crt_series.patch_exists(args[0]):
            # it might be just a commit id
            patches = args
        else:
            patches = parse_patches(args, applied + unapplied +\
                                crt_series.get_hidden(), len(applied))

    if options.diff_opts:
        diff_flags = options.diff_opts.split()
    else:
        diff_flags = []

    commit_ids = [git_id(patch) for patch in patches]
    commit_str = '\n'.join([git.pretty_commit(commit_id, diff_flags=diff_flags)
                            for commit_id in commit_ids])
    if commit_str:
        pager(commit_str)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:31,代码来源:show.py


示例14: main

def main():
    parser = argparse.ArgumentParser(prog='rfcs', description=description)
    parser.add_argument('--version', action='store_true')
    subparsers = parser.add_subparsers(title='subcommands', dest='command')
    parser_search = subparsers.add_parser('search', help='search for RFCs matching a query')
    parser_search.add_argument('query', type=str, help='search query')
    parser_search.add_argument('--maxresults', type=int, dest='N', metavar='N',
                               default=5, help='maximum number of displayed results')
    parser_info = subparsers.add_parser('info', help='get information on a particular RFC')
    parser_info.add_argument('rfc', type=int, help='number of RFC')
    parser_text = subparsers.add_parser('text', help='view the text of a particular RFC')
    parser_text.add_argument('rfc', type=int, help='number of RFC')
    parser_text.add_argument('--nopager', action='store_true',
                             help='write to stdout instead of opening pager')
    parser_url = subparsers.add_parser('url', help='get a URL to view a particular RFC')
    parser_url.add_argument('rfc', type=int, help='number of RFC')
    parser_url.add_argument('--format', choices=['text', 'html', 'pdf', 'bibtex'], default='text')
    args = parser.parse_args()
    if args.version:
        print(__version__)
    elif args.command == 'search':
        print(search(args.query, args.N))
    elif args.command == 'info':
        print(info(args.rfc))
    elif args.command == 'text':
        if args.nopager:
            print(text(args.rfc))
        else:
            pydoc.pager(text(args.rfc))
    elif args.command == 'url':
        print(url(args.rfc, args.format))
    else:
        parser.print_help()
开发者ID:lucasem,项目名称:rfcs,代码行数:33,代码来源:rfcs.py


示例15: help

 def help(self, request):
     global _img
     topbar = '_' * 72 + '\n' # 72-character divider
     if hasattr(request, '__name__'):
         pydoc.pager(topbar + 'Help on ' + pydoc.text.bold(request.__name__)
                     + ':\n\n' + pydoc.getdoc(request))
     else:
         opts = _img.opts.__class__.__dict__
         try:
             opt = opts[request]
             desc_list = str(opt.doc()).split('\n')
             desc = '\n\n'.join(desc_list)
             default_val = opt._default
             if isinstance(default_val, str):
                 valstr = "'" + default_val + "'"
             else:
                 valstr = str(default_val)
             default_val_text = 'Default value: ' + valstr
             if opt.group() != None and opt.group() != 'hidden':
                 group_text = '\nBelongs to group: ' + opt.group()
             else:
                 group_text = ''
             desc_text = lofar.bdsm.interface.wrap(desc, 72)
             desc_text = '\n'.join(desc_text)
             pydoc.pager(topbar + 'Help on the ' + pydoc.text.bold(request)
                         + ' parameter:\n\n' + default_val_text
                         + group_text
                         + '\n\n' + desc_text)
         except(KeyError):
             print "Parameter '" + request + "' not recognized."
开发者ID:saiyanprince,项目名称:pyimager,代码行数:30,代码来源:pybdsm.py


示例16: search

def search(args: object) -> int:
    """ Search for search_term in filename.

    """

    filename = args.filename
    search_term = args.search_term

    # Read the accounts dictionary into accounts_dict.
    accounts_dict, _, master_key = read_file(filename)

    search_str = search_term.lower()

    # String to store all matching account information.
    account_str = ""

    for account_data in accounts_dict.values():
        # Search through every account that can be decrypted with
        # the password, or ask for a password for each account.
        account_dict = crypt_to_dict(account_data, master_key)

        # If the password could decrypt the account, info search
        # throuth every key and value in the account.
        if account_dict:
            for key, value in account_dict.items():
                if search_str in key.lower() or search_str in value.lower():
                    account_str += "\n" + dict_to_str(account_dict)
                    # Don't add the same account more than once.
                    break
    import pydoc

    pydoc.pager(account_str)

    return 0
开发者ID:zepto,项目名称:lessinfo,代码行数:34,代码来源:lessinfo_new.py


示例17: doc2

def doc2(thing, title="Python Library Documentation: %s", forceload=0):
    """Display text documentation, given an object or a path to an object."""
    import types

    try:
        object, name = pydoc.resolve(thing, forceload)
        desc = pydoc.describe(object)
        module = mygetmodule(object)
        if name and "." in name:
            desc += " in " + name[: name.rfind(".")]
        elif module and module is not object:
            desc += " in module " + module.__name__

        if not (
            inspect.ismodule(object)
            or inspect.isclass(object)
            or inspect.isroutine(object)
            or isinstance(object, property)
        ):
            # If the passed object is a piece of data or an instance,
            # document its available methods instead of its value.

            # if this is a instance of used defined old-style class
            if type(object) == types.InstanceType:
                object = object.__class__
            else:
                object = type(object)
            desc += " object"
        pydoc.pager(title % desc + "\n\n" + pydoc.text.document(object, name))
    except (ImportError, pydoc.ErrorDuringImport), value:
        print value
开发者ID:wvengen,项目名称:lgipilot,代码行数:31,代码来源:gangadoc.py


示例18: __call__

 def __call__(self, parser, namespace, values, option_string=None):
     output = StringIO()
     parser.print_help(output)
     text = output.getvalue()
     output.close()
     pydoc.pager(text)
     parser.exit()
开发者ID:catkin,项目名称:xylem,代码行数:7,代码来源:arguments.py


示例19: get_changelog

def get_changelog(pkg_name:str, interactive:bool=False, output:bool=False,
    paged_output:bool=False, no_local:bool=False, max_download_size:int=0):
    """ Returns changelog for given package name, if any, and if within
        size-restrictions
    """
    changelog = None
    try:
        if not apt_changelog:
            __init__(interactive)
        if int(max_download_size) > 0:
            apt_changelog.max_download_size = int(max_download_size)
        else:
            apt_changelog.max_download_size = apt_changelog.max_download_size_default
        changelog = apt_changelog.get_changelog(pkg_name, no_local)
    except SystemExit:
        if interactive:
            raise
    except KeyboardInterrupt:
        sys.exit(130)
    else:
        if output:
            if not changelog:
                # empty changelog
                apt_changelog.exit_on_fail(7)
            if paged_output:
                try:
                    from pydoc import pager
                    pager(changelog)
                except Exception as e:
                    _generic_exception_handler(e)
                    paged_output = False
            else:
                print(changelog)
    return changelog
开发者ID:linuxmint,项目名称:mint-common,代码行数:34,代码来源:apt_changelog.py


示例20: search

def search(args: object) -> int:
    """ Search for search_term in filename.

    """

    filename = args.filename
    search_term = args.search_term

    search_str = search_term.lower()

    # String in which to store all matching account information.
    account_str = ""

    with PassFile(filename) as passfile:
        for account_dict in passfile.accounts():
            # The string representation of a dict is good enough for
            # searching in.
            if search_str in str(account_dict):
                account_str += "\n" + dict_to_str(account_dict)

    import pydoc

    pydoc.pager(account_str)

    return 0
开发者ID:zepto,项目名称:lessinfo,代码行数:25,代码来源:passmgr_gcrypt.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pydoc.plain函数代码示例发布时间:2022-05-25
下一篇:
Python pydoc.locate函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap