예제 #1
0
def _line_key(line_elements):
    """
    Given a sequence of elements comprising a single line, returns an orderable value to use in ordering lines.
    """
    for e in line_elements:
        if isinstance(e, TokenElement) and tokens.is_string(e.first_token):
            return e.primitive_value
    return 'z' * 10     # Metadata lines should be at the end
예제 #2
0
def _line_key(line_elements):
    """
    Given a sequence of elements comprising a single line, returns an orderable value to use in ordering lines.
    """
    for e in line_elements:
        if isinstance(e, TokenElement) and tokens.is_string(e.first_token):
            return e.primitive_value
    return 'z' * 10  # Metadata lines should be at the end
예제 #3
0
 def multiline_equivalent(element):
     if isinstance(element, AtomicElement) and tokens.is_string(element.first_token):
         return element_factory.create_multiline_string(element.value, MAXIMUM_LINE_LENGTH)
     elif isinstance(element, ArrayElement):
         element.turn_into_multiline()
         return element
     else:
         return element
예제 #4
0
 def multiline_equivalent(element):
     if isinstance(element, AtomicElement) and tokens.is_string(
             element.first_token):
         return element_factory.create_multiline_string(
             element.value, MAXIMUM_LINE_LENGTH)
     elif isinstance(element, ArrayElement):
         element.turn_into_multiline()
         return element
     else:
         return element