]> arthur.barton.de Git - bup.git/commitdiff
Use sys.platform instead of platform.system().
authorRob Browning <rlb@defaultvalue.org>
Mon, 27 May 2013 15:27:51 +0000 (10:27 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 27 May 2013 17:28:51 +0000 (12:28 -0500)
If nothing else, the former is computed at compile time, and so should
be more efficient.  Use the recommended "startswith()" idiom.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
cmd/ftp-cmd.py
lib/bup/helpers.py
lib/bup/metadata.py
lib/bup/t/tmetadata.py

index 6c40dc37bc3bc87e52449d8fb21dcbfa74bf933d..baa1e08d826cb1064f7c15762398a62247d37ddb 100755 (executable)
@@ -144,7 +144,7 @@ else:
     if readline:
         readline.set_completer_delims(' \t\n\r/')
         readline.set_completer(completer)
-        if platform.system() == 'Darwin':
+        if sys.platform.startswith('darwin'):
             # MacOS uses a slighly incompatible clone of libreadline
             readline.parse_and_bind('bind ^I rl_complete')
         readline.parse_and_bind('tab: complete')
index 339c6d735277d0400d2bcbcdfc759192588704b3..ef2e368e2f4875d3eb362d237720e329b52cd09a 100644 (file)
@@ -1,7 +1,7 @@
 """Helper functions and classes for bup."""
 
 import sys, os, pwd, subprocess, errno, socket, select, mmap, stat, re, struct
-import hashlib, heapq, operator, time, platform, grp
+import hashlib, heapq, operator, time, grp
 from bup import _version, _helpers
 import bup._helpers as _helpers
 
@@ -204,7 +204,7 @@ def detect_fakeroot():
 
 
 def is_superuser():
-    if platform.system().startswith('CYGWIN'):
+    if sys.platform.startswith('cygwin'):
         import ctypes
         return ctypes.cdll.shell32.IsUserAnAdmin()
     else:
index 27e1a2393ccf03edadd6f0493b71319e2c419e28..c317eee487a8f118dd4dbc04a89d6c0d2a637bd3 100644 (file)
@@ -4,7 +4,7 @@
 #
 # This code is covered under the terms of the GNU Library General
 # Public License as described in the bup LICENSE file.
-import errno, os, sys, stat, time, platform, pwd, grp
+import errno, os, sys, stat, time, pwd, grp
 from cStringIO import StringIO
 from bup import vint, xstat
 from bup.drecurse import recursive_dirlist
@@ -13,7 +13,7 @@ from bup.helpers import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name
 from bup.xstat import utime, lutime
 
 xattr = None
-if 'Linux' in platform.system():
+if sys.platform.startswith('linux'):
     try:
         import xattr
     except ImportError:
@@ -27,7 +27,7 @@ if 'Linux' in platform.system():
             xattr = None
 
 posix1e = None
-if not 'CYGWIN' in platform.system():
+if not sys.platform.startswith('cygwin'):
     try:
         import posix1e
     except ImportError:
index c957e7d2f3c9ace5147ab1236c4406bbcdfa4340..689bbba905b0616b84c4d65109d42c01896ad49a 100644 (file)
@@ -1,4 +1,4 @@
-import glob, grp, platform, pwd, stat, tempfile, subprocess
+import glob, grp, pwd, stat, tempfile, subprocess
 import bup.helpers as helpers
 from bup import git, metadata, vfs
 from bup.helpers import clear_errors, detect_fakeroot, is_superuser
@@ -28,7 +28,7 @@ def ex(*cmd):
 
 
 def setup_testfs():
-    assert('Linux' in platform.system())
+    assert(sys.platform.startswith('linux'))
     # Set up testfs with user_xattr, etc.
     subprocess.call(['umount', 'testfs'])
     ex('dd', 'if=/dev/zero', 'of=testfs.img', 'bs=1M', 'count=32')
@@ -179,7 +179,7 @@ def test_from_path_error():
 def test_apply_to_path_restricted_access():
     if is_superuser() or detect_fakeroot():
         return
-    if 'CYGWIN' in platform.system():
+    if sys.platform.startswith('cygwin'):
         return # chmod 000 isn't effective.
     tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
     try: