Generic formatter for pretty printing InstallRequirements to the terminal
    in a less verbose way than using its `__str__` method.
774267
def format_requirement(ireq):
    

    if ireq.editable:
        line = "-e {}".format(ireq.link)
    else:
        line = _requirement_to_str_lowercase_name(ireq.req)

    if str(ireq.req.marker) != str(ireq.markers):
        if not ireq.req.marker:
            line = "{}; {}".format(line, ireq.markers)
        else:
            name, markers = line.split(";", 1)
            markers = markers.strip()
            line = "{}; ({}) and ({})".format(name, markers, ireq.markers)

    return line
284938
def pretty_format(obj, indent=None):
        
        if indent is None:
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
                    '{}={}'.format(k, TLObject.pretty_format(v))
                    for k, v in obj.items() if k != '_'
                ))
            elif isinstance(obj, str) or isinstance(obj, bytes):
                return repr(obj)
            elif hasattr(obj, '__iter__'):
                return '[{}]'.format(
                    ', '.join(TLObject.pretty_format(x) for x in obj)
                )
            else:
                return repr(obj)
        else:
            result = []
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                result.append(obj.get('_', 'dict'))
                result.append('(')
                if obj:
                    result.append('\n')
                    indent += 1
                    for k, v in obj.items():
                        if k == '_':
                            continue
                        result.append('\t' * indent)
                        result.append(k)
                        result.append('=')
                        result.append(TLObject.pretty_format(v, indent))
                        result.append(',\n')
                    result.pop()  # last ',\n'
                    indent -= 1
                    result.append('\n')
                    result.append('\t' * indent)
                result.append(')')

            elif isinstance(obj, str) or isinstance(obj, bytes):
                result.append(repr(obj))

            elif hasattr(obj, '__iter__'):
                result.append('[\n')
                indent += 1
                for x in obj:
                    result.append('\t' * indent)
                    result.append(TLObject.pretty_format(x, indent))
                    result.append(',\n')
                indent -= 1
                result.append('\t' * indent)
                result.append(']')

            else:
                result.append(repr(obj))

            return ''.join(result)
459431
def pformat(obj, verbose=False):
    
    try:
        from pretty import pretty
        return pretty(obj, verbose=verbose)
    except ImportError:
        from pprint import pformat
        return pformat(obj)
413317
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        condition = pretty_str(self.condition)
        pretty = '{}switch ({}):\n'.format(spaces, condition)
        pretty += self.body.pretty_str(indent=indent + 2)
        return pretty
706955
def script_repr(self,imports=[],prefix="    "):
        
        return self.pprint(imports,prefix,unknown_value='',qualify=True,
                           separator="\n")
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)
1317012
def pretty(self):
        '''
        
        '''
        return '{}:{} in {}.{}'.format(
            self.filename,
            self.line_number,
            self.module_name,
            self.function_name)
1168190
def pretty_format_args(*args, **kwargs):
    
    args = list([repr(a) for a in args])
    for key, value in kwargs.items():
        args.append("%s=%s" % (key, repr(value)))
    return "(%s)" % ", ".join([a for a in args])
644664
def pretty(self, obj=None, display=True):
        
        ret = self._format_obj(obj if obj is not None else self.obj)
        if display:
            print(ret)
        else:
            return ret
998034
def pprint(self, file_=sys.stdout):
        

        code = []
        if self._deps:
            code.append("# dependencies:")
        for k, v in _compat.iteritems(self._deps):
            code.append("#   %s: %r" % (k, v))
        code.append(str(self))
        code = "\n".join(code)

        if file_.isatty():
            try:
                from pygments import highlight
                from pygments.lexers import PythonLexer
                from pygments.formatters import TerminalFormatter
            except ImportError:
                pass
            else:
                formatter = TerminalFormatter(bg="dark")
                lexer = PythonLexer()
                file_.write(highlight(code, lexer, formatter))
                return
        file_.write(code + "\n")
51722
def prettyPrintDictionary(d):
    ''''''
    maxKeyLength = 0
    maxValueLength = 0
    for key, value in d.iteritems():
        maxKeyLength = max(maxKeyLength, len(key))
        maxValueLength = max(maxValueLength, len(key))
    for key in sorted(d.keys()):
        print ("%"+str(maxKeyLength)+"s : %-" + str(maxValueLength)+ "s") % (key,d[key])
176389
def pygments_required(func):
    """"""
    def wrapper(*args, **kwargs):
        if not HAS_PYGMENTS:  # pragma: no cover
            raise ImportError(
                "Please install 'pygments' library to use syntax_color.")
        rv = func(*args, **kwargs)
        return rv
    return wrapper
79958
def __dumps(*args, **kwargs):
    
    indent = None
    if (current_app.config.get('JSONIFY_PRETTYPRINT_REGULAR', False) and
            not request.is_xhr):
        indent = 2
    return json.dumps(args[0] if len(args) is 1 else dict(*args, **kwargs),
                      indent=indent)
781079
def _format_args():
    """"""
    # Ensure we can run outside a application/request context.
    try:
        pretty_format = \
            current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and \
            not request.is_xhr
    except RuntimeError:
        pretty_format = False

    if pretty_format:
        return dict(
            indent=2,
            separators=(', ', ': '),
        )
    else:
        return dict(
            indent=None,
            separators=(',', ':'),
        )
19316
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        return spaces + ', '.join(v.pretty_str() for v in self.variables)
666754
def preparse(output_format):
    
    try:
        return templating.preparse(output_format, lambda path: os.path.join(config.config_dir, "templates", path))
    except ImportError as exc:
        if "tempita" in str(exc):
            raise error.UserError("To be able to use Tempita templates, install the 'tempita' package (%s)\n"
                "    Possibly USING THE FOLLOWING COMMAND:\n"
                "        %s/easy_install tempita" % (exc, os.path.dirname(sys.executable)))
        raise
    except IOError as exc:
        raise error.LoggableError("Cannot read template: {}".format(exc))
402413
def pretty_str(self, indent=0):
        
        indent = ' ' * indent
        if self.value is not None:
            return '{}{} {}'.format(indent, self.name, pretty_str(self.value))
        return indent + self.name