Prints a manpage, all pretty and paged.
 Returns the terminal-formatted manpage, ready to be printed to
 the screen.
178499
def manpage(name)
      return "** Can't find groff(1)" unless groff?

      require 'open3'
      out = nil
      Open3.popen3(groff_command) do |stdin, stdout, _|
        stdin.puts raw_manpage(name)
        stdin.close
        out = stdout.read.strip
      end
      out
    end
328005
def print(self, *args, **kwargs):
        '''
        
        '''
        if self._last_args and self._last_args.verbose:
            print(*args, **kwargs)
779881
def printer(text, color=None, **kwargs):
    
    if nocolor:
        # import sys
        # sys.stdout.write(text + "" if ("end" in kwargs and kwargs["end"] == "") else '\n')
        # sys.stdout.flush()
        print(text, **kwargs)
    else:
        if color is None:
            cprint(text, **kwargs)
        else:
            cprint(text, color, **kwargs)
971947
def prettyprint(d):
        
        print(json.dumps(d, sort_keys=True, 
                         indent=4, separators=("," , ": ")))
432133
def pretty_print(self, warnings=False):
        
        msg = []
        if (warnings) and (len(self.warnings) > 0):
            msg.append(u"Warnings:")
            for warning in self.warnings:
                msg.append(u"  %s" % warning)
        if len(self.errors) > 0:
            msg.append(u"Errors:")
            for error in self.errors:
                msg.append(u"  %s" % error)
        return u"\n".join(msg)
949594
def render_page(page, page_args):
    
    print(page_args)
    template_name = page.template if page.template else page.name
    template = "signage/pages/{}.html".format(template_name)
    if page.function:
        context_method = getattr(pages, page.function)
    else:
        context_method = getattr(pages, page.name)
    sign, request = page_args
    context = context_method(page, sign, request)
    return render_to_string(template, context)
482102
def print_help(self, *args, **kwargs):
        
        if self._command is not None and self._command.session.allow_pager:
            desc = 'Help\: %s' % '-'.join(self.prog.split())
            pager_kwargs = self._command.get_pager_spec()
            with paging.pager_redirect(desc, **pager_kwargs):
                return super().print_help(*args, **kwargs)
        else:
                return super().print_help(*args, **kwargs)
848931
def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
    

    print((colored(text, color, on_color, attrs)), **kwargs)
216922
def get_layout(self, page):
        
        if type(page) == int:
            page = self.get_page(page)
        self.interpreter.process_page(page)
        layout = self.device.get_result()
        layout = self._add_annots(layout, page.annots)
        return layout
441492
def cprint(msg, reset=True, template=ColorTemplate):
    
    print(cformat(msg, reset, template))
272819
def print_out(self, value, indent=None, format_options=None, asap=False):
        
        if indent is None:
            indent = '>   '

        text = indent + str(value)

        if format_options is None:
            format_options = 'gray'

        if self._style_prints and format_options:

            if not isinstance(format_options, dict):
                format_options = {'color_fg': format_options}

            text = format_print_text(text, **format_options)

        command = 'iprint' if asap else 'print'
        self._set(command, text, multi=True)

        return self
406832
def print_page_cb(self, print_op, print_context, page_nb, keep_refs={}):
        
        page = ImgPage(self, page_nb)
        page.print_page_cb(print_op, print_context, keep_refs=keep_refs)
63071
def _print_html(self):
        
        cur_path = os.path.dirname(os.path.realpath(sys.argv[0]))
        shutil.copytree(cur_path+'webpage/template/', '')
168237
def page(self):
        
        if not self._page:
            try:
                self._page = self.paginator.page(
                    self.query_dict.get('page', 1))
            except InvalidPage:
                raise HttpError("Invalid page", status=HTTP_400_BAD_REQUEST)
        return self._page
485894
def _print_original_webpage(
            self):
        
        self.log.debug('starting the ``_print_original_webpage`` method')

        if not self.title:
            r = requests.get(self.url)
            title = bs4.BeautifulSoup(r.text).title.text
            print title
        else:
            title = self.title

        # CONVERT TO PDF WITH ELECTON PDF

        url = self.url
        pdfPath = self.folderpath + "/" + title + self.append + ".pdf"
        electron = self.settings["executables"]["electron path"]
        cmd = """%(electron)s -i "%(url)s" -o "%(pdfPath)s" --printBackground """ % locals()
        p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
        stdout, stderr = p.communicate()
        self.log.debug('output: %(stdout)s' % locals())
        if len(stderr):
            print stderr

        exists = os.path.exists(pdfPath)
        if not exists:
            print "%(pdfPath)s was not generated for some reason - please investigate" % locals()
            sys.exit(0)

        self.log.debug('completed the ``_print_original_webpage`` method')
        return pdfPath
1065988
def print(self, *args, **kwargs):
        
        print(self, *args, **kwargs)
        self.data = ''
        return self
1202146
def print_with_pager(output):
    """"""
    if sys.stdout.isatty():
        try:
            pager = subprocess.Popen(
                ['less', '-F', '-r', '-S', '-X', '-K'],
                stdin=subprocess.PIPE, stdout=sys.stdout)
        except subprocess.CalledProcessError:
            # Don't use the pager since starting it has failed.
            print(output)
            return
        else:
            pager.stdin.write(output.encode('utf-8'))
            pager.stdin.close()
            pager.wait()
    else:
        # Output directly to stdout since not in tty.
        print(output)