Python pydoc 模块,pager() 实例源码

我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用pydoc.pager()

项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def _showPorts(self, ports, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        if ports:
            table = TablePrinter('Port Name', 'Port Interface')
            for port in ports.itervalues():
                table.append(port['Port Name'], port['Port Interface'])
            table.write(f=destfile)
        else:
            print >>destfile, "None"

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, "Provides (Input) Ports =============="
        self._showPorts(self._providesPortDict, destfile=destfile)
        print >>destfile, "\n"

        print >>destfile, "Uses (Output) Ports =============="
        self._showPorts(self._usesPortDict, destfile=destfile)
        print >>destfile, "\n"

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, 'Allocation Properties ======'
        if not self._allocProps:
            print >>destfile, 'None'
            return

        table = TablePrinter('Property Name', '(Data Type)', 'Action')
        for prop in self._allocProps:
            table.append(prop.clean_name, '('+prop.type+')', prop.action)
            if prop.type in ('struct', 'structSeq'):
                if prop.type == 'structSeq':
                    structdef = prop.structDef
                else:
                    structdef = prop
                for member in structdef.members.itervalues():
                    table.append('  '+member.clean_name, member.type)
        table.write(f=destfile)
        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, showComponentName=True, showInterfaces=True, showProperties=True, externalPropInfo=None, destfile=None):
        '''
        Inspect interfaces and properties for the component
        '''
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        className = self.__class__.__name__
        if showComponentName == True:
            print >>destfile, className+" [" + str(self.name) + "]:"
        if showInterfaces == True:
            PortSupplier.api(self, destfile=destfile)
        if showProperties == True and self._properties != None:
            PropertySet.api(self, externalPropInfo, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        """
        Prints application programming interface (API) information and returns.

        """
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, "Component " + self.__class__.__name__ + " :"
        PortSupplier.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        '''
        Inspect interfaces and properties for the component
        '''
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, "Component [" + str(self._componentName) + "]:"
        PortSupplier.api(self, destfile=destfile)
        PropertySet.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:jiveplot    作者:haavee    | 项目源码 | 文件源码
def maybePage(lst):
    screenSize = getScreenSize()
    # be more intelligent about it
    doPage = None
    if screenSize:
        # count the number of lines the text would use up on the screen
        # (taking care of lines longer than the terminal width)
        doPage = sum( \
            map(lambda x: \
                sum( map(lambda y: \
                          int(math.ceil(float(len(y) if len(y) else 1)/float(screenSize[1]))), x.split('\n') \
                    ) \
                ), lst \
            )) > screenSize[0]
    if doPage or not screenSize:
        pydoc.pager("\n".join(lst))
    else:
        def p(x):
            print x
        map(p, lst)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def pager_print(expr, **settings):
    """Prints expr using the pager, in pretty form.

    This invokes a pager command using pydoc. Lines are not wrapped
    automatically. This routine is meant to be used with a pager that allows
    sideways scrolling, like ``less -S``.

    Parameters are the same as for ``pretty_print``. If you wish to wrap lines,
    pass ``num_columns=None`` to auto-detect the width of the terminal.

    """
    from pydoc import pager
    from locale import getpreferredencoding
    if 'num_columns' not in settings:
        settings['num_columns'] = 500000  # disable line wrap
    pager(pretty(expr, **settings).encode(getpreferredencoding()))
项目:Python-iBeacon-Scan    作者:NikNitro    | 项目源码 | 文件源码
def pager_print(expr, **settings):
    """Prints expr using the pager, in pretty form.

    This invokes a pager command using pydoc. Lines are not wrapped
    automatically. This routine is meant to be used with a pager that allows
    sideways scrolling, like ``less -S``.

    Parameters are the same as for ``pretty_print``. If you wish to wrap lines,
    pass ``num_columns=None`` to auto-detect the width of the terminal.

    """
    from pydoc import pager
    from locale import getpreferredencoding
    if 'num_columns' not in settings:
        settings['num_columns'] = 500000  # disable line wrap
    pager(pretty(expr, **settings).encode(getpreferredencoding()))
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        super(DomainDevice,self).api(destfile=destfile)
        print >>destfile, '\n'
        model.Device.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, "Component MessageSink :"
        PortSupplier.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        print >>destfile, "Component MessageSource :"
        PortSupplier.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def api(self, destfile=None):
        localdef_dest = False
        if destfile == None:
            localdef_dest = True
            destfile = cStringIO.StringIO()

        SandboxResource.api(self, destfile=destfile)
        print >>destfile, '\n'
        Device.api(self, destfile=destfile)

        if localdef_dest:
            pydoc.pager(destfile.getvalue())
            destfile.close()
项目:git-reviewers    作者:johnnadratowski    | 项目源码 | 文件源码
def get_blame(filename, start, num_lines, branch):
    cmd = "git --no-pager blame -L {start},+{num_lines} {branch} -- {file}"
    cmd = cmd.format(start=start, num_lines=num_lines, branch=branch, file=filename)
    return run_cmd(cmd)
项目:git-reviewers    作者:johnnadratowski    | 项目源码 | 文件源码
def get_diff_raw(branch):
    cmd = "git --no-pager diff --raw {branch}"
    cmd = cmd.format(branch=branch)
    return run_cmd(cmd)
项目:git-reviewers    作者:johnnadratowski    | 项目源码 | 文件源码
def get_file_diff(from_name, to_name, branch):
    if to_name:
        cmd = "git --no-pager diff {branch} -- {to_name} -- {from_name}"
        cmd = cmd.format(branch=branch, from_name=from_name, to_name=to_name)
    else:
        cmd = "git --no-pager diff {branch} -- {file}"
        cmd = cmd.format(branch=branch, file=from_name)

    return run_cmd(cmd)
项目:git-reviewers    作者:johnnadratowski    | 项目源码 | 文件源码
def print_contributer_lines(contributer, diff_infos):
    output = []
    for diff_info in diff_infos:
        lines = diff_info["reviewers"].get(contributer)
        if not lines:
            continue

        shl.print_section(shl.BOLD, diff_info["from_hash"], diff_info["file"], file=output)

        prev_line = None
        for line in lines:
            try:
                from pygments import highlight
                from pygments.lexers import PythonLexer
                from pygments.formatters import TerminalFormatter

                code = highlight(line["code_line"], PythonLexer(), TerminalFormatter())
            except ImportError:
                code = line["code_line"]

            cur_line = int(line["line_num"])

            if prev_line and prev_line + 1 < cur_line:
                output.append("    .")
                output.append("    .")
                output.append("    .")
            output.append("{line_num: >5}|\t{code_line}".format(line_num=line["line_num"], code_line=code.rstrip()))

            prev_line = cur_line

        output.append("\n\n")

    pydoc.pager("\n".join(output))
项目:projects    作者:tiborsimon    | 项目源码 | 文件源码
def show_project_details(data, width):
    doc = doc_generator.generate_doc(data, width)
    doc = doc.format(
        head='\033[0;33m',
        project='\033[1;36m',
        command='\033[1;33m',
        reset='\033[0m'
    )
    pydoc.pipepager(doc, cmd='less -R')
    # pydoc.pager(doc)
项目:jiveplot    作者:haavee    | 项目源码 | 文件源码
def listScans(self, *args):
        pfx = "listScans:"
        if not self.msname:
            print pfx,"No MS loaded yet"
            return None
        if not self.scanlist:
            print pfx, "No scans (yet) - have you run the 'indexr' task?"
            return None
        # print list of scan id's + text
        lines = "\n".join( map(str, self.scanlist) )
        if args and '-p' in args:
            pydoc.pager( lines )
        else:
            print lines
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def help():
    import pydoc
    pydoc.pager(__doc__)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def help():
    import pydoc
    pydoc.pager(__doc__)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def help():
    import pydoc
    pydoc.pager(__doc__)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def help():
    import pydoc
    pydoc.pager(__doc__)
项目:jupyter-casa    作者:aardk    | 项目源码 | 文件源码
def help(self, request):
        if hasattr(request, 'i_am_a_casapy_task'):
            pydoc.pager('Help on ' + pydoc.text.bold(request.__name__) + ' task:\n\n' + request.__doc__)
        else:
            return pydoc.Helper.help(self, request)
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def pip_notes():
        os.system('cls' if sys.platform == 'win32' else 'clear')
        pydoc.pager('''
    If installing via PyPi (Python Pip) on Linux then you need to know that VidCutter
    depends on the following packages, grouped by distro. Install using your
    Linux software packager for a noticeably better integrated experience.

        ---[Ubuntu/Debian/Mint/etc]--------------------------

            python3-dev libmpv1 libmpv-dev python3-pyqt5
            python3-pyqt5.qtopengl ffmpeg mediainfo

        ---[Arch Linux]--------------------------------------

            python mpv python-pyqt5 ffmpeg mediainfo

        ---[Fedora]------------------------------------------

            python3-devel mpv-libs mpv-libs-devel python3-qt5
            ffmpeg mediainfo

        ---[openSUSE]----------------------------------------

            python3-devel libmpv1 mpv-devel python3-qt5
            ffmpeg mediainfo 

    You need to build a Python extension module before you can run the
    app directly from source code. This is done for you automatically by
    the package installers but if you wish to simply run the app direct
    from source without having to install it (i.e. python3 setup.py install)
    you can do so by building the extension module with the following
    setuptools command, run from the top-most extracted source code folder:

        $ python3 setup.py build_ext -i

    And to then run the app directly from source, from the same top-most
    source code folder:

        $ python3 -m vidcutter

    To view all console output for debugging or general interest then
    append the debug parameter:

        $ python3 -m vidcutter --debug

    Make sure you build the extension module AFTER installing the
    dependencies covered above, in particular libmpv and the mpv + python3
    dev headers are all needed for it to compile successfully. Compiled
    extension modules under vidcutter/libs will look like:

        mpv.cpython-36m-x86_64-linux-gnu.so [linux]
        mpv.cp36-win_amd64.pyd              [win32]

    Windows users must do all this within a Visual Studio 2015/2017 Native x64/x86
    Developer Command Prompt accessible from your Visual Studio program group
    via the start menu. It's easier to just grab the prebuilt Windows installers
    directly from:

        https://github.com/ozmartian/vidcutter/releases/latest
''')