import os
import sys
-import types
def dodir(path):
os.spawnlp(os.P_WAIT, "install", "install", "-d", path)
(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 + "'"
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
# 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.
"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
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
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)
finally:
os.umask(old_mask)
- elif type(mypath) == types.IntType:
+ elif isinstance(mypath, int):
myfd = mypath
else:
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)
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)
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)
# 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