Did I find the right examples for you? yes no

All Samples(10)  |  Call(4)  |  Derive(0)  |  Import(6)

        def tuplize_comments(prefix):
    # This tuplizes the newlines before and after the prefix
    # Given '\n\n\n    # test comment\n    \n'
    # returns (['\n\n\n'], ['    # test comment\n'], ['    \n'])

    if not prefix:
        return ('', '', '')

    # If there are no newlines, this was just a trailing comment. Leave it
    # alone.
    if not prefix.count('\n'):
        return ('', prefix, '')

    if prefix.count("#"):
        whitespace_before_first_comment = prefix[:prefix.index("#")]
        start_of_comment = whitespace_before_first_comment.rfind('\n')
        if prefix.count('\n') and not prefix.split('\n')[-1].strip():
            # Add a single newline back if there was a newline in the ending
            # whitespace
            comments = "%s\n" % prefix[start_of_comment + 1:].rstrip()
        else:
            comments = prefix[start_of_comment + 1:].rstrip()
    else:
        if prefix.count('\n'):
            comments = prefix.rsplit('\n')[1]
            # If no comments, there are no comments except the trailing spaces
            # before the current line
        else:
            comments = prefix
    comments_start = prefix.index(comments)
    return prefix[:comments_start].strip(' '), comments, prefix[
        comments_start + len(comments):]
        


src/p/e/pep8ify-HEAD/pep8ify/fixes/fix_maximum_line_length.py   pep8ify(Download)
from textwrap import TextWrapper
 
from .utils import (tuplize_comments, get_quotes, wrap_leaves,
    first_child_leaf, find_indentation, IS_26, add_leaves_method)
 
    def fix_prefix(self, node):
        before_comments, comments, after_comments = tuplize_comments(node.
            prefix)
 
        # Combine all comment lines together

src/p/e/pep8ify-0.0.11/pep8ify/fixes/fix_maximum_line_length.py   pep8ify(Download)
from textwrap import TextWrapper
 
from .utils import (tuplize_comments, get_quotes, wrap_leaves,
    first_child_leaf, find_indentation, IS_26, add_leaves_method)
 
    def fix_prefix(self, node):
        before_comments, comments, after_comments = tuplize_comments(node.
            prefix)
 
        # Combine all comment lines together

src/p/e/pep8ify-HEAD/pep8ify/fixes/fix_blank_lines.py   pep8ify(Download)
from lib2to3.pygram import python_symbols as symbols
 
from .utils import (get_whitespace_before_definition, has_parent,
    tuplize_comments)
 
    def trim_comments(self, curr_node_indentation, previous_whitespace,
        min_lines_between_defs, max_lines_between_defs):
        before_comments, comments, after_comments = tuplize_comments(
            previous_whitespace)
 

src/p/e/pep8ify-0.0.11/pep8ify/fixes/fix_blank_lines.py   pep8ify(Download)
from lib2to3.pygram import python_symbols as symbols
 
from .utils import (get_whitespace_before_definition, has_parent,
    tuplize_comments)
 
    def trim_comments(self, curr_node_indentation, previous_whitespace,
        min_lines_between_defs, max_lines_between_defs):
        before_comments, comments, after_comments = tuplize_comments(
            previous_whitespace)
 

src/p/e/pep8ify-HEAD/tests/fixtures/maximum_line_length/maximum_line_length1_out.py   pep8ify(Download)
    line else u'' for line in "new_prefix".split('\n')]).rstrip(u' ') +
    "another long string")
from .utils import (get_whitespace_before_definition, has_parent,
    tuplize_comments)
before_comments, comments, after_comments_and_this_string_goes_on = (

src/p/e/pep8ify-HEAD/tests/fixtures/maximum_line_length/maximum_line_length1_in.py   pep8ify(Download)
    pass
new_prefix = '\n'.join([u"%s%s" % ("new_comment_indent", line.lstrip()) if line else u'' for line in "new_prefix".split('\n')]).rstrip(u' ') + "another long string"
from .utils import get_whitespace_before_definition, has_parent, tuplize_comments
before_comments, comments, after_comments_and_this_string_goes_on = tuplize_comments(u"asjdfsjf js ffsadasdfsf")