diff options
-rwxr-xr-x | bin/dohtml | 4 | ||||
-rw-r--r-- | pym/_emerge/__init__.py | 6 | ||||
-rw-r--r-- | pym/portage/dep.py | 4 | ||||
-rw-r--r-- | pym/portage/locks.py | 23 |
4 files changed, 17 insertions, 20 deletions
diff --git a/bin/dohtml b/bin/dohtml index 56f95bbfa..1c707bdfd 100755 --- a/bin/dohtml +++ b/bin/dohtml @@ -31,7 +31,6 @@ import os import sys -import types def dodir(path): os.spawnlp(os.P_WAIT, "install", "install", "-d", path) @@ -160,9 +159,6 @@ def main(): (options, args) = parse_args() - if type(options.allowed_exts) == types.StringType: - options.allowed_exts = options.allowed_exts.split(",") - if options.verbose: print "Allowed extensions:", options.allowed_exts print "Document prefix : '" + options.doc_prefix + "'" diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 00ef6f705..0200ce30c 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -32,7 +32,7 @@ from portage import digraph from portage.const import NEWS_LIB_PATH import _emerge.help -import portage.xpak, commands, errno, re, socket, time, types +import portage.xpak, commands, errno, re, socket, time from portage.output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \ nc_len, red, teal, turquoise, xtermTitle, \ xtermTitleReset, yellow @@ -277,8 +277,8 @@ def countdown(secs=5, doing="Starting"): # formats a size given in bytes nicely def format_size(mysize): - if type(mysize) not in [types.IntType,types.LongType]: - return str(mysize) + if isinstance(mysize, basestring): + return mysize if 0 != mysize % 1024: # Always round up to the next kB so that it doesn't show 0 kB when # some small file still needs to be fetched. diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 831a8a324..04817068c 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -18,7 +18,7 @@ # "a? ( b? ( z ) ) -- Valid # -import re, sys, types +import re, sys import weakref from itertools import chain import portage.exception @@ -230,7 +230,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]): while mydeparray: head = mydeparray.pop(0) - if type(head) == types.ListType: + if not isinstance(head, basestring): additions = use_reduce(head, uselist, masklist, matchall, excludeall) if additions: rlist.append(additions) diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 50fe317bf..36bc085bf 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -7,7 +7,7 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \ "hardlock_name", "hardlink_is_mine", "hardlink_lockfile", \ "unhardlink_lockfile", "hardlock_cleanup"] -import errno, os, stat, time, types +import errno, os, stat, time from portage.exception import DirectoryNotFound, FileNotFound, \ InvalidData, TryAgain, OperationNotPermitted, PermissionDenied from portage.data import portage_gid @@ -35,12 +35,12 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, if not mypath: raise InvalidData("Empty path given") - if type(mypath) == types.StringType and mypath[-1] == '/': + if isinstance(mypath, basestring) and mypath[-1] == '/': mypath = mypath[:-1] - if type(mypath) == types.FileType: + if hasattr(mypath, 'fileno'): mypath = mypath.fileno() - if type(mypath) == types.IntType: + if isinstance(mypath, int): lockfilename = mypath wantnewlockfile = 0 unlinkfile = 0 @@ -51,8 +51,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, unlinkfile = 1 else: lockfilename = mypath - - if type(mypath) == types.StringType: + + if isinstance(mypath, basestring): if not os.path.exists(os.path.dirname(mypath)): raise DirectoryNotFound(os.path.dirname(mypath)) preexisting = os.path.exists(lockfilename) @@ -86,7 +86,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, finally: os.umask(old_mask) - elif type(mypath) == types.IntType: + elif isinstance(mypath, int): myfd = mypath else: @@ -142,7 +142,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, raise - if type(lockfilename) == types.StringType and \ + if isinstance(lockfilename, basestring) and \ myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0: # The file was deleted on us... Keep trying to make one... os.close(myfd) @@ -187,7 +187,8 @@ def unlockfile(mytuple): return True # myfd may be None here due to myfd = mypath in lockfile() - if type(lockfilename) == types.StringType and not os.path.exists(lockfilename): + if isinstance(lockfilename, basestring) and \ + not os.path.exists(lockfilename): writemsg("lockfile does not exist '%s'\n" % lockfilename,1) if myfd is not None: os.close(myfd) @@ -199,7 +200,7 @@ def unlockfile(mytuple): unlinkfile = 1 locking_method(myfd,fcntl.LOCK_UN) except OSError: - if type(lockfilename) == types.StringType: + if isinstance(lockfilename, basestring): os.close(myfd) raise IOError("Failed to unlock file '%s'\n" % lockfilename) @@ -230,7 +231,7 @@ def unlockfile(mytuple): # why test lockfilename? because we may have been handed an # fd originally, and the caller might not like having their # open fd closed automatically on them. - if type(lockfilename) == types.StringType: + if isinstance(lockfilename, basestring): os.close(myfd) return True |