~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Mark Hammond
  • Date: 2008-12-28 05:21:23 UTC
  • mfrom: (3920 +trunk)
  • mto: (3932.1.1 prepare-1.11)
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mhammond@skippinet.com.au-20081228052123-f78xs5sbdkotshwf
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
812
812
            rps.append(f)
813
813
    return rps
814
814
 
 
815
 
815
816
def joinpath(p):
816
817
    for f in p:
817
818
        if (f == '..') or (f is None) or (f == ''):
819
820
    return pathjoin(*p)
820
821
 
821
822
 
 
823
try:
 
824
    from bzrlib._chunks_to_lines_pyx import chunks_to_lines
 
825
except ImportError:
 
826
    from bzrlib._chunks_to_lines_py import chunks_to_lines
 
827
 
 
828
 
822
829
def split_lines(s):
823
830
    """Split s into lines, but without removing the newline characters."""
 
831
    # Trivially convert a fulltext into a 'chunked' representation, and let
 
832
    # chunks_to_lines do the heavy lifting.
 
833
    if isinstance(s, str):
 
834
        # chunks_to_lines only supports 8-bit strings
 
835
        return chunks_to_lines([s])
 
836
    else:
 
837
        return _split_lines(s)
 
838
 
 
839
 
 
840
def _split_lines(s):
 
841
    """Split s into lines, but without removing the newline characters.
 
842
 
 
843
    This supports Unicode or plain string objects.
 
844
    """
824
845
    lines = s.split('\n')
825
846
    result = [line + '\n' for line in lines[:-1]]
826
847
    if lines[-1]: