Did I find the right examples for you? yes no

All Samples(208)  |  Call(177)  |  Derive(0)  |  Import(31)
Clean up indentation from docstrings.

Any whitespace that can be uniformly removed from the second line
onwards is removed.

        def cleandoc(doc):
    """Clean up indentation from docstrings.

    Any whitespace that can be uniformly removed from the second line
    onwards is removed."""
    try:
        lines = string.split(string.expandtabs(doc), '\n')
    except UnicodeError:
        return None
    else:
        # Find minimum indentation of any non-blank lines after first line.
        margin = sys.maxint
        for line in lines[1:]:
            content = len(string.lstrip(line))
            if content:
                indent = len(line) - content
                margin = min(margin, indent)
        # Remove indentation.
        if lines:
            lines[0] = lines[0].lstrip()
        if margin < sys.maxint:
            for i in range(1, len(lines)): lines[i] = lines[i][margin:]
        # Remove any trailing or leading blank lines.
        while lines and not lines[-1]:
            lines.pop()
        while lines and not lines[0]:
            lines.pop(0)
        return string.join(lines, '\n')
        


src/a/u/AutobahnPython-HEAD/examples/twisted/wamp/work/test2.py   AutobahnPython(Download)
print(inspect.getargspec(add2))
print(get_class_default_arg(add2, Foo))
print(inspect.cleandoc(add2.__doc__))
 

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/IPython/core/oinspect.py   antisocial(Download)
        # if we get extra info, we add it to the normal docstring.
        if isinstance(ds, basestring):
            return inspect.cleandoc(ds)
 
    try:

src/i/p/ipython-2.0.0/IPython/core/oinspect.py   ipython(Download)
        # if we get extra info, we add it to the normal docstring.
        if isinstance(ds, string_types):
            return inspect.cleandoc(ds)
 
    try:

src/i/p/ipython-HEAD/IPython/core/oinspect.py   ipython(Download)
        # if we get extra info, we add it to the normal docstring.
        if isinstance(ds, string_types):
            return inspect.cleandoc(ds)
 
    try:

src/d/e/dexy-1.0.6/dexy/utils.py   dexy(Download)
    except ValueError as e:
        msg = inspect.cleandoc(u"""Was unable to parse the JSON you supplied.
        Here is information from the JSON parser:""")
        msg += u"\n"
        msg += unicode(e)
    except ValueError as e:
        msg = inspect.cleandoc(u"""Was unable to parse the JSON you supplied.
        Here is information from the JSON parser:""")
        msg += u"\n"
        msg += unicode(e)
        else:
            msg = inspect.cleandoc(u"""Was unable to parse the YAML you supplied.
            Here is information from the YAML parser:""")
            msg += u"\n"
            msg += unicode(e)
    except (yaml.scanner.ScannerError, yaml.parser.ParserError) as e:
        msg = inspect.cleandoc(u"""Was unable to parse the YAML you supplied.
        Here is information from the YAML parser:""")
        msg += u"\n"
        msg += unicode(e)

src/d/e/dexy-HEAD/dexy/utils.py   dexy(Download)
    except ValueError as e:
        msg = inspect.cleandoc(u"""Was unable to parse the JSON you supplied.
        Here is information from the JSON parser:""")
        msg += u"\n"
        msg += unicode(e)
    except ValueError as e:
        msg = inspect.cleandoc(u"""Was unable to parse the JSON you supplied.
        Here is information from the JSON parser:""")
        msg += u"\n"
        msg += unicode(e)
        else:
            msg = inspect.cleandoc(u"""Was unable to parse the YAML you supplied.
            Here is information from the YAML parser:""")
            msg += u"\n"
            msg += unicode(e)
    except (yaml.scanner.ScannerError, yaml.parser.ParserError) as e:
        msg = inspect.cleandoc(u"""Was unable to parse the YAML you supplied.
        Here is information from the YAML parser:""")
        msg += u"\n"
        msg += unicode(e)

src/p/y/python-string-scanner-HEAD/scripts/gendoc.py   python-string-scanner(Download)
def format_doc(doc):
  if doc is None: doc = ''
  doc = inspect.cleandoc(doc)
  # slow
  regex = '|'.join( [m[0] for m in methods] + [m[0] for m in getset] )

src/p/d/pdoc-0.2.1/pdoc/__init__.py   pdoc(Download)
        """
 
        self.docstring = inspect.cleandoc(docstring or '')
        """
        The docstring for this object. It has already been cleaned
            if isinstance(dobj, External):
                continue
            dobj.docstring = inspect.cleandoc(docstring)
 
    def text(self):

src/p/d/pdoc-HEAD/pdoc/__init__.py   pdoc(Download)
        """
 
        self.docstring = inspect.cleandoc(docstring or '')
        """
        The docstring for this object. It has already been cleaned
            if isinstance(dobj, External):
                continue
            dobj.docstring = inspect.cleandoc(docstring)
 
    def text(self):

src/g/a/Gaea-0.0.1/gaea/api.py   Gaea(Download)
    if not body.strip():
        body = source.partition("\n")[2]
    return inspect.cleandoc(body)
 

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next