/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-13 20:33:57 UTC
  • mfrom: (2283 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070213203357-b7yg41mi9sk6cqd0
[merge] bzr.dev 2283
resolve conflicts in moved repository formats
small issue with osutils.contains_whitespace()

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from shutil import (
41
41
    rmtree,
42
42
    )
43
 
import string
44
43
import tempfile
45
44
from tempfile import (
46
45
    mkdtemp,
48
47
import unicodedata
49
48
 
50
49
from bzrlib import (
 
50
    cache_utf8,
51
51
    errors,
52
 
    cache_utf8,
 
52
    win32utils,
53
53
    )
54
54
""")
55
55
 
778
778
 
779
779
def contains_whitespace(s):
780
780
    """True if there are any whitespace characters in s."""
781
 
    for ch in string.whitespace:
 
781
    # string.whitespace can include '\xa0' in certain locales, because it is
 
782
    # considered "non-breaking-space" as part of ISO-8859-1. But it
 
783
    # 1) Isn't a breaking whitespace
 
784
    # 2) Isn't one of ' \t\r\n' which are characters we sometimes use as
 
785
    #    separators
 
786
    # 3) '\xa0' isn't unicode safe since it is >128.
 
787
 
 
788
    # This should *not* be a unicode set of characters in case the source
 
789
    # string is not a Unicode string. We can auto-up-cast the characters since
 
790
    # they are ascii, but we don't want to auto-up-cast the string in case it
 
791
    # is utf-8
 
792
    for ch in ' \t\n\r\v\f':
782
793
        if ch in s:
783
794
            return True
784
795
    else:
928
939
def terminal_width():
929
940
    """Return estimated terminal width."""
930
941
    if sys.platform == 'win32':
931
 
        import bzrlib.win32console
932
 
        return bzrlib.win32console.get_console_size()[0]
 
942
        return win32utils.get_console_size()[0]
933
943
    width = 0
934
944
    try:
935
945
        import struct, fcntl, termios
953
963
    return sys.platform != "win32"
954
964
 
955
965
 
 
966
def supports_posix_readonly():
 
967
    """Return True if 'readonly' has POSIX semantics, False otherwise.
 
968
 
 
969
    Notably, a win32 readonly file cannot be deleted, unlike POSIX where the
 
970
    directory controls creation/deletion, etc.
 
971
 
 
972
    And under win32, readonly means that the directory itself cannot be
 
973
    deleted.  The contents of a readonly directory can be changed, unlike POSIX
 
974
    where files in readonly directories cannot be added, deleted or renamed.
 
975
    """
 
976
    return sys.platform != "win32"
 
977
 
 
978
 
956
979
def set_or_unset_env(env_variable, value):
957
980
    """Modify the environment, setting or removing the env_variable.
958
981