598
599
raise BzrBadParameter(unicode_or_utf8_string)
602
_platform_normalizes_filenames = False
603
if sys.platform == 'darwin':
604
_platform_normalizes_filenames = True
607
def normalizes_filenames():
608
"""Return True if this platform normalizes unicode filenames.
610
Mac OSX does, Windows/Linux do not.
612
return _platform_normalizes_filenames
615
if _platform_normalizes_filenames:
616
def unicode_filename(path):
617
"""Make sure 'path' is a properly normalized filename.
619
On platforms where the system normalizes filenames (Mac OSX),
620
you can access a file by any path which will normalize
622
Internally, bzr only supports NFC/NFKC normalization, since
623
that is the standard for XML documents.
624
So we return an normalized path, and indicate this has been
627
:return: (path, is_normalized) Return a path which can
628
access the file, and whether or not this path is
631
return unicodedata.normalize('NFKC', path), True
633
def unicode_filename(path):
634
"""Make sure 'path' is a properly normalized filename.
636
On platforms where the system does not normalize filenames
637
(Windows, Linux), you have to access a file by its exact path.
638
Internally, bzr only supports NFC/NFKC normalization, since
639
that is the standard for XML documents.
640
So we return the original path, and indicate if this is
643
:return: (path, is_normalized) Return a path which can
644
access the file, and whether or not this path is
647
return path, unicodedata.normalize('NFKC', path) == path
601
650
def terminal_width():
602
651
"""Return estimated terminal width."""