644
645
raise BzrBadParameterNotUnicode(unicode_or_utf8_string)
648
_platform_normalizes_filenames = False
649
if sys.platform == 'darwin':
650
_platform_normalizes_filenames = True
653
def normalizes_filenames():
654
"""Return True if this platform normalizes unicode filenames.
656
Mac OSX does, Windows/Linux do not.
658
return _platform_normalizes_filenames
661
if _platform_normalizes_filenames:
662
def unicode_filename(path):
663
"""Make sure 'path' is a properly normalized filename.
665
On platforms where the system normalizes filenames (Mac OSX),
666
you can access a file by any path which will normalize
668
Internally, bzr only supports NFC/NFKC normalization, since
669
that is the standard for XML documents.
670
So we return an normalized path, and indicate this has been
673
:return: (path, is_normalized) Return a path which can
674
access the file, and whether or not this path is
677
return unicodedata.normalize('NFKC', path), True
679
def unicode_filename(path):
680
"""Make sure 'path' is a properly normalized filename.
682
On platforms where the system does not normalize filenames
683
(Windows, Linux), you have to access a file by its exact path.
684
Internally, bzr only supports NFC/NFKC normalization, since
685
that is the standard for XML documents.
686
So we return the original path, and indicate if this is
689
:return: (path, is_normalized) Return a path which can
690
access the file, and whether or not this path is
693
return path, unicodedata.normalize('NFKC', path) == path
647
696
def terminal_width():
648
697
"""Return estimated terminal width."""