Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/python27/lib64/python2....
File: os.py
r"""OS routines for NT or Posix depending on what system we're on.
[0] Fix | Delete
[1] Fix | Delete
This exports:
[2] Fix | Delete
- all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
[3] Fix | Delete
- os.path is one of the modules posixpath, or ntpath
[4] Fix | Delete
- os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos'
[5] Fix | Delete
- os.curdir is a string representing the current directory ('.' or ':')
[6] Fix | Delete
- os.pardir is a string representing the parent directory ('..' or '::')
[7] Fix | Delete
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
[8] Fix | Delete
- os.extsep is the extension separator ('.' or '/')
[9] Fix | Delete
- os.altsep is the alternate pathname separator (None or '/')
[10] Fix | Delete
- os.pathsep is the component separator used in $PATH etc
[11] Fix | Delete
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
[12] Fix | Delete
- os.defpath is the default search path for executables
[13] Fix | Delete
- os.devnull is the file path of the null device ('/dev/null', etc.)
[14] Fix | Delete
[15] Fix | Delete
Programs that import and use 'os' stand a better chance of being
[16] Fix | Delete
portable between different platforms. Of course, they must then
[17] Fix | Delete
only use functions that are defined by all platforms (e.g., unlink
[18] Fix | Delete
and opendir), and leave all pathname manipulation to os.path
[19] Fix | Delete
(e.g., split and join).
[20] Fix | Delete
"""
[21] Fix | Delete
[22] Fix | Delete
#'
[23] Fix | Delete
[24] Fix | Delete
import sys, errno
[25] Fix | Delete
[26] Fix | Delete
_names = sys.builtin_module_names
[27] Fix | Delete
[28] Fix | Delete
# Note: more names are added to __all__ later.
[29] Fix | Delete
__all__ = ["altsep", "curdir", "pardir", "sep", "extsep", "pathsep", "linesep",
[30] Fix | Delete
"defpath", "name", "path", "devnull",
[31] Fix | Delete
"SEEK_SET", "SEEK_CUR", "SEEK_END"]
[32] Fix | Delete
[33] Fix | Delete
def _get_exports_list(module):
[34] Fix | Delete
try:
[35] Fix | Delete
return list(module.__all__)
[36] Fix | Delete
except AttributeError:
[37] Fix | Delete
return [n for n in dir(module) if n[0] != '_']
[38] Fix | Delete
[39] Fix | Delete
if 'posix' in _names:
[40] Fix | Delete
name = 'posix'
[41] Fix | Delete
linesep = '\n'
[42] Fix | Delete
from posix import *
[43] Fix | Delete
try:
[44] Fix | Delete
from posix import _exit
[45] Fix | Delete
except ImportError:
[46] Fix | Delete
pass
[47] Fix | Delete
import posixpath as path
[48] Fix | Delete
[49] Fix | Delete
import posix
[50] Fix | Delete
__all__.extend(_get_exports_list(posix))
[51] Fix | Delete
del posix
[52] Fix | Delete
[53] Fix | Delete
elif 'nt' in _names:
[54] Fix | Delete
name = 'nt'
[55] Fix | Delete
linesep = '\r\n'
[56] Fix | Delete
from nt import *
[57] Fix | Delete
try:
[58] Fix | Delete
from nt import _exit
[59] Fix | Delete
except ImportError:
[60] Fix | Delete
pass
[61] Fix | Delete
import ntpath as path
[62] Fix | Delete
[63] Fix | Delete
import nt
[64] Fix | Delete
__all__.extend(_get_exports_list(nt))
[65] Fix | Delete
del nt
[66] Fix | Delete
[67] Fix | Delete
elif 'os2' in _names:
[68] Fix | Delete
name = 'os2'
[69] Fix | Delete
linesep = '\r\n'
[70] Fix | Delete
from os2 import *
[71] Fix | Delete
try:
[72] Fix | Delete
from os2 import _exit
[73] Fix | Delete
except ImportError:
[74] Fix | Delete
pass
[75] Fix | Delete
if sys.version.find('EMX GCC') == -1:
[76] Fix | Delete
import ntpath as path
[77] Fix | Delete
else:
[78] Fix | Delete
import os2emxpath as path
[79] Fix | Delete
from _emx_link import link
[80] Fix | Delete
[81] Fix | Delete
import os2
[82] Fix | Delete
__all__.extend(_get_exports_list(os2))
[83] Fix | Delete
del os2
[84] Fix | Delete
[85] Fix | Delete
elif 'ce' in _names:
[86] Fix | Delete
name = 'ce'
[87] Fix | Delete
linesep = '\r\n'
[88] Fix | Delete
from ce import *
[89] Fix | Delete
try:
[90] Fix | Delete
from ce import _exit
[91] Fix | Delete
except ImportError:
[92] Fix | Delete
pass
[93] Fix | Delete
# We can use the standard Windows path.
[94] Fix | Delete
import ntpath as path
[95] Fix | Delete
[96] Fix | Delete
import ce
[97] Fix | Delete
__all__.extend(_get_exports_list(ce))
[98] Fix | Delete
del ce
[99] Fix | Delete
[100] Fix | Delete
elif 'riscos' in _names:
[101] Fix | Delete
name = 'riscos'
[102] Fix | Delete
linesep = '\n'
[103] Fix | Delete
from riscos import *
[104] Fix | Delete
try:
[105] Fix | Delete
from riscos import _exit
[106] Fix | Delete
except ImportError:
[107] Fix | Delete
pass
[108] Fix | Delete
import riscospath as path
[109] Fix | Delete
[110] Fix | Delete
import riscos
[111] Fix | Delete
__all__.extend(_get_exports_list(riscos))
[112] Fix | Delete
del riscos
[113] Fix | Delete
[114] Fix | Delete
else:
[115] Fix | Delete
raise ImportError, 'no os specific module found'
[116] Fix | Delete
[117] Fix | Delete
sys.modules['os.path'] = path
[118] Fix | Delete
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
[119] Fix | Delete
devnull)
[120] Fix | Delete
[121] Fix | Delete
del _names
[122] Fix | Delete
[123] Fix | Delete
# Python uses fixed values for the SEEK_ constants; they are mapped
[124] Fix | Delete
# to native constants if necessary in posixmodule.c
[125] Fix | Delete
SEEK_SET = 0
[126] Fix | Delete
SEEK_CUR = 1
[127] Fix | Delete
SEEK_END = 2
[128] Fix | Delete
[129] Fix | Delete
#'
[130] Fix | Delete
[131] Fix | Delete
# Super directory utilities.
[132] Fix | Delete
# (Inspired by Eric Raymond; the doc strings are mostly his)
[133] Fix | Delete
[134] Fix | Delete
def makedirs(name, mode=0777):
[135] Fix | Delete
"""makedirs(path [, mode=0777])
[136] Fix | Delete
[137] Fix | Delete
Super-mkdir; create a leaf directory and all intermediate ones.
[138] Fix | Delete
Works like mkdir, except that any intermediate path segment (not
[139] Fix | Delete
just the rightmost) will be created if it does not exist. This is
[140] Fix | Delete
recursive.
[141] Fix | Delete
[142] Fix | Delete
"""
[143] Fix | Delete
head, tail = path.split(name)
[144] Fix | Delete
if not tail:
[145] Fix | Delete
head, tail = path.split(head)
[146] Fix | Delete
if head and tail and not path.exists(head):
[147] Fix | Delete
try:
[148] Fix | Delete
makedirs(head, mode)
[149] Fix | Delete
except OSError, e:
[150] Fix | Delete
# be happy if someone already created the path
[151] Fix | Delete
if e.errno != errno.EEXIST:
[152] Fix | Delete
raise
[153] Fix | Delete
if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
[154] Fix | Delete
return
[155] Fix | Delete
mkdir(name, mode)
[156] Fix | Delete
[157] Fix | Delete
def removedirs(name):
[158] Fix | Delete
"""removedirs(path)
[159] Fix | Delete
[160] Fix | Delete
Super-rmdir; remove a leaf directory and all empty intermediate
[161] Fix | Delete
ones. Works like rmdir except that, if the leaf directory is
[162] Fix | Delete
successfully removed, directories corresponding to rightmost path
[163] Fix | Delete
segments will be pruned away until either the whole path is
[164] Fix | Delete
consumed or an error occurs. Errors during this latter phase are
[165] Fix | Delete
ignored -- they generally mean that a directory was not empty.
[166] Fix | Delete
[167] Fix | Delete
"""
[168] Fix | Delete
rmdir(name)
[169] Fix | Delete
head, tail = path.split(name)
[170] Fix | Delete
if not tail:
[171] Fix | Delete
head, tail = path.split(head)
[172] Fix | Delete
while head and tail:
[173] Fix | Delete
try:
[174] Fix | Delete
rmdir(head)
[175] Fix | Delete
except error:
[176] Fix | Delete
break
[177] Fix | Delete
head, tail = path.split(head)
[178] Fix | Delete
[179] Fix | Delete
def renames(old, new):
[180] Fix | Delete
"""renames(old, new)
[181] Fix | Delete
[182] Fix | Delete
Super-rename; create directories as necessary and delete any left
[183] Fix | Delete
empty. Works like rename, except creation of any intermediate
[184] Fix | Delete
directories needed to make the new pathname good is attempted
[185] Fix | Delete
first. After the rename, directories corresponding to rightmost
[186] Fix | Delete
path segments of the old name will be pruned until either the
[187] Fix | Delete
whole path is consumed or a nonempty directory is found.
[188] Fix | Delete
[189] Fix | Delete
Note: this function can fail with the new directory structure made
[190] Fix | Delete
if you lack permissions needed to unlink the leaf directory or
[191] Fix | Delete
file.
[192] Fix | Delete
[193] Fix | Delete
"""
[194] Fix | Delete
head, tail = path.split(new)
[195] Fix | Delete
if head and tail and not path.exists(head):
[196] Fix | Delete
makedirs(head)
[197] Fix | Delete
rename(old, new)
[198] Fix | Delete
head, tail = path.split(old)
[199] Fix | Delete
if head and tail:
[200] Fix | Delete
try:
[201] Fix | Delete
removedirs(head)
[202] Fix | Delete
except error:
[203] Fix | Delete
pass
[204] Fix | Delete
[205] Fix | Delete
__all__.extend(["makedirs", "removedirs", "renames"])
[206] Fix | Delete
[207] Fix | Delete
def walk(top, topdown=True, onerror=None, followlinks=False):
[208] Fix | Delete
"""Directory tree generator.
[209] Fix | Delete
[210] Fix | Delete
For each directory in the directory tree rooted at top (including top
[211] Fix | Delete
itself, but excluding '.' and '..'), yields a 3-tuple
[212] Fix | Delete
[213] Fix | Delete
dirpath, dirnames, filenames
[214] Fix | Delete
[215] Fix | Delete
dirpath is a string, the path to the directory. dirnames is a list of
[216] Fix | Delete
the names of the subdirectories in dirpath (excluding '.' and '..').
[217] Fix | Delete
filenames is a list of the names of the non-directory files in dirpath.
[218] Fix | Delete
Note that the names in the lists are just names, with no path components.
[219] Fix | Delete
To get a full path (which begins with top) to a file or directory in
[220] Fix | Delete
dirpath, do os.path.join(dirpath, name).
[221] Fix | Delete
[222] Fix | Delete
If optional arg 'topdown' is true or not specified, the triple for a
[223] Fix | Delete
directory is generated before the triples for any of its subdirectories
[224] Fix | Delete
(directories are generated top down). If topdown is false, the triple
[225] Fix | Delete
for a directory is generated after the triples for all of its
[226] Fix | Delete
subdirectories (directories are generated bottom up).
[227] Fix | Delete
[228] Fix | Delete
When topdown is true, the caller can modify the dirnames list in-place
[229] Fix | Delete
(e.g., via del or slice assignment), and walk will only recurse into the
[230] Fix | Delete
subdirectories whose names remain in dirnames; this can be used to prune the
[231] Fix | Delete
search, or to impose a specific order of visiting. Modifying dirnames when
[232] Fix | Delete
topdown is false is ineffective, since the directories in dirnames have
[233] Fix | Delete
already been generated by the time dirnames itself is generated. No matter
[234] Fix | Delete
the value of topdown, the list of subdirectories is retrieved before the
[235] Fix | Delete
tuples for the directory and its subdirectories are generated.
[236] Fix | Delete
[237] Fix | Delete
By default errors from the os.listdir() call are ignored. If
[238] Fix | Delete
optional arg 'onerror' is specified, it should be a function; it
[239] Fix | Delete
will be called with one argument, an os.error instance. It can
[240] Fix | Delete
report the error to continue with the walk, or raise the exception
[241] Fix | Delete
to abort the walk. Note that the filename is available as the
[242] Fix | Delete
filename attribute of the exception object.
[243] Fix | Delete
[244] Fix | Delete
By default, os.walk does not follow symbolic links to subdirectories on
[245] Fix | Delete
systems that support them. In order to get this functionality, set the
[246] Fix | Delete
optional argument 'followlinks' to true.
[247] Fix | Delete
[248] Fix | Delete
Caution: if you pass a relative pathname for top, don't change the
[249] Fix | Delete
current working directory between resumptions of walk. walk never
[250] Fix | Delete
changes the current directory, and assumes that the client doesn't
[251] Fix | Delete
either.
[252] Fix | Delete
[253] Fix | Delete
Example:
[254] Fix | Delete
[255] Fix | Delete
import os
[256] Fix | Delete
from os.path import join, getsize
[257] Fix | Delete
for root, dirs, files in os.walk('python/Lib/email'):
[258] Fix | Delete
print root, "consumes",
[259] Fix | Delete
print sum([getsize(join(root, name)) for name in files]),
[260] Fix | Delete
print "bytes in", len(files), "non-directory files"
[261] Fix | Delete
if 'CVS' in dirs:
[262] Fix | Delete
dirs.remove('CVS') # don't visit CVS directories
[263] Fix | Delete
[264] Fix | Delete
"""
[265] Fix | Delete
[266] Fix | Delete
islink, join, isdir = path.islink, path.join, path.isdir
[267] Fix | Delete
[268] Fix | Delete
# We may not have read permission for top, in which case we can't
[269] Fix | Delete
# get a list of the files the directory contains. os.path.walk
[270] Fix | Delete
# always suppressed the exception then, rather than blow up for a
[271] Fix | Delete
# minor reason when (say) a thousand readable directories are still
[272] Fix | Delete
# left to visit. That logic is copied here.
[273] Fix | Delete
try:
[274] Fix | Delete
# Note that listdir and error are globals in this module due
[275] Fix | Delete
# to earlier import-*.
[276] Fix | Delete
names = listdir(top)
[277] Fix | Delete
except error, err:
[278] Fix | Delete
if onerror is not None:
[279] Fix | Delete
onerror(err)
[280] Fix | Delete
return
[281] Fix | Delete
[282] Fix | Delete
dirs, nondirs = [], []
[283] Fix | Delete
for name in names:
[284] Fix | Delete
if isdir(join(top, name)):
[285] Fix | Delete
dirs.append(name)
[286] Fix | Delete
else:
[287] Fix | Delete
nondirs.append(name)
[288] Fix | Delete
[289] Fix | Delete
if topdown:
[290] Fix | Delete
yield top, dirs, nondirs
[291] Fix | Delete
for name in dirs:
[292] Fix | Delete
new_path = join(top, name)
[293] Fix | Delete
if followlinks or not islink(new_path):
[294] Fix | Delete
for x in walk(new_path, topdown, onerror, followlinks):
[295] Fix | Delete
yield x
[296] Fix | Delete
if not topdown:
[297] Fix | Delete
yield top, dirs, nondirs
[298] Fix | Delete
[299] Fix | Delete
__all__.append("walk")
[300] Fix | Delete
[301] Fix | Delete
# Make sure os.environ exists, at least
[302] Fix | Delete
try:
[303] Fix | Delete
environ
[304] Fix | Delete
except NameError:
[305] Fix | Delete
environ = {}
[306] Fix | Delete
[307] Fix | Delete
def execl(file, *args):
[308] Fix | Delete
"""execl(file, *args)
[309] Fix | Delete
[310] Fix | Delete
Execute the executable file with argument list args, replacing the
[311] Fix | Delete
current process. """
[312] Fix | Delete
execv(file, args)
[313] Fix | Delete
[314] Fix | Delete
def execle(file, *args):
[315] Fix | Delete
"""execle(file, *args, env)
[316] Fix | Delete
[317] Fix | Delete
Execute the executable file with argument list args and
[318] Fix | Delete
environment env, replacing the current process. """
[319] Fix | Delete
env = args[-1]
[320] Fix | Delete
execve(file, args[:-1], env)
[321] Fix | Delete
[322] Fix | Delete
def execlp(file, *args):
[323] Fix | Delete
"""execlp(file, *args)
[324] Fix | Delete
[325] Fix | Delete
Execute the executable file (which is searched for along $PATH)
[326] Fix | Delete
with argument list args, replacing the current process. """
[327] Fix | Delete
execvp(file, args)
[328] Fix | Delete
[329] Fix | Delete
def execlpe(file, *args):
[330] Fix | Delete
"""execlpe(file, *args, env)
[331] Fix | Delete
[332] Fix | Delete
Execute the executable file (which is searched for along $PATH)
[333] Fix | Delete
with argument list args and environment env, replacing the current
[334] Fix | Delete
process. """
[335] Fix | Delete
env = args[-1]
[336] Fix | Delete
execvpe(file, args[:-1], env)
[337] Fix | Delete
[338] Fix | Delete
def execvp(file, args):
[339] Fix | Delete
"""execvp(file, args)
[340] Fix | Delete
[341] Fix | Delete
Execute the executable file (which is searched for along $PATH)
[342] Fix | Delete
with argument list args, replacing the current process.
[343] Fix | Delete
args may be a list or tuple of strings. """
[344] Fix | Delete
_execvpe(file, args)
[345] Fix | Delete
[346] Fix | Delete
def execvpe(file, args, env):
[347] Fix | Delete
"""execvpe(file, args, env)
[348] Fix | Delete
[349] Fix | Delete
Execute the executable file (which is searched for along $PATH)
[350] Fix | Delete
with argument list args and environment env , replacing the
[351] Fix | Delete
current process.
[352] Fix | Delete
args may be a list or tuple of strings. """
[353] Fix | Delete
_execvpe(file, args, env)
[354] Fix | Delete
[355] Fix | Delete
__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
[356] Fix | Delete
[357] Fix | Delete
def _execvpe(file, args, env=None):
[358] Fix | Delete
if env is not None:
[359] Fix | Delete
func = execve
[360] Fix | Delete
argrest = (args, env)
[361] Fix | Delete
else:
[362] Fix | Delete
func = execv
[363] Fix | Delete
argrest = (args,)
[364] Fix | Delete
env = environ
[365] Fix | Delete
[366] Fix | Delete
head, tail = path.split(file)
[367] Fix | Delete
if head:
[368] Fix | Delete
func(file, *argrest)
[369] Fix | Delete
return
[370] Fix | Delete
if 'PATH' in env:
[371] Fix | Delete
envpath = env['PATH']
[372] Fix | Delete
else:
[373] Fix | Delete
envpath = defpath
[374] Fix | Delete
PATH = envpath.split(pathsep)
[375] Fix | Delete
saved_exc = None
[376] Fix | Delete
saved_tb = None
[377] Fix | Delete
for dir in PATH:
[378] Fix | Delete
fullname = path.join(dir, file)
[379] Fix | Delete
try:
[380] Fix | Delete
func(fullname, *argrest)
[381] Fix | Delete
except error, e:
[382] Fix | Delete
tb = sys.exc_info()[2]
[383] Fix | Delete
if (e.errno != errno.ENOENT and e.errno != errno.ENOTDIR
[384] Fix | Delete
and saved_exc is None):
[385] Fix | Delete
saved_exc = e
[386] Fix | Delete
saved_tb = tb
[387] Fix | Delete
if saved_exc:
[388] Fix | Delete
raise error, saved_exc, saved_tb
[389] Fix | Delete
raise error, e, tb
[390] Fix | Delete
[391] Fix | Delete
# Change environ to automatically call putenv() if it exists
[392] Fix | Delete
try:
[393] Fix | Delete
# This will fail if there's no putenv
[394] Fix | Delete
putenv
[395] Fix | Delete
except NameError:
[396] Fix | Delete
pass
[397] Fix | Delete
else:
[398] Fix | Delete
import UserDict
[399] Fix | Delete
[400] Fix | Delete
# Fake unsetenv() for Windows
[401] Fix | Delete
# not sure about os2 here but
[402] Fix | Delete
# I'm guessing they are the same.
[403] Fix | Delete
[404] Fix | Delete
if name in ('os2', 'nt'):
[405] Fix | Delete
def unsetenv(key):
[406] Fix | Delete
putenv(key, "")
[407] Fix | Delete
[408] Fix | Delete
if name == "riscos":
[409] Fix | Delete
# On RISC OS, all env access goes through getenv and putenv
[410] Fix | Delete
from riscosenviron import _Environ
[411] Fix | Delete
elif name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE
[412] Fix | Delete
# But we store them as upper case
[413] Fix | Delete
class _Environ(UserDict.IterableUserDict):
[414] Fix | Delete
def __init__(self, environ):
[415] Fix | Delete
UserDict.UserDict.__init__(self)
[416] Fix | Delete
data = self.data
[417] Fix | Delete
for k, v in environ.items():
[418] Fix | Delete
data[k.upper()] = v
[419] Fix | Delete
def __setitem__(self, key, item):
[420] Fix | Delete
putenv(key, item)
[421] Fix | Delete
self.data[key.upper()] = item
[422] Fix | Delete
def __getitem__(self, key):
[423] Fix | Delete
return self.data[key.upper()]
[424] Fix | Delete
try:
[425] Fix | Delete
unsetenv
[426] Fix | Delete
except NameError:
[427] Fix | Delete
def __delitem__(self, key):
[428] Fix | Delete
del self.data[key.upper()]
[429] Fix | Delete
else:
[430] Fix | Delete
def __delitem__(self, key):
[431] Fix | Delete
unsetenv(key)
[432] Fix | Delete
del self.data[key.upper()]
[433] Fix | Delete
def clear(self):
[434] Fix | Delete
for key in self.data.keys():
[435] Fix | Delete
unsetenv(key)
[436] Fix | Delete
del self.data[key]
[437] Fix | Delete
def pop(self, key, *args):
[438] Fix | Delete
unsetenv(key)
[439] Fix | Delete
return self.data.pop(key.upper(), *args)
[440] Fix | Delete
def has_key(self, key):
[441] Fix | Delete
return key.upper() in self.data
[442] Fix | Delete
def __contains__(self, key):
[443] Fix | Delete
return key.upper() in self.data
[444] Fix | Delete
def get(self, key, failobj=None):
[445] Fix | Delete
return self.data.get(key.upper(), failobj)
[446] Fix | Delete
def update(self, dict=None, **kwargs):
[447] Fix | Delete
if dict:
[448] Fix | Delete
try:
[449] Fix | Delete
keys = dict.keys()
[450] Fix | Delete
except AttributeError:
[451] Fix | Delete
# List of (key, value)
[452] Fix | Delete
for k, v in dict:
[453] Fix | Delete
self[k] = v
[454] Fix | Delete
else:
[455] Fix | Delete
# got keys
[456] Fix | Delete
# cannot use items(), since mappings
[457] Fix | Delete
# may not have them.
[458] Fix | Delete
for k in keys:
[459] Fix | Delete
self[k] = dict[k]
[460] Fix | Delete
if kwargs:
[461] Fix | Delete
self.update(kwargs)
[462] Fix | Delete
def copy(self):
[463] Fix | Delete
return dict(self)
[464] Fix | Delete
[465] Fix | Delete
else: # Where Env Var Names Can Be Mixed Case
[466] Fix | Delete
class _Environ(UserDict.IterableUserDict):
[467] Fix | Delete
def __init__(self, environ):
[468] Fix | Delete
UserDict.UserDict.__init__(self)
[469] Fix | Delete
self.data = environ
[470] Fix | Delete
def __setitem__(self, key, item):
[471] Fix | Delete
putenv(key, item)
[472] Fix | Delete
self.data[key] = item
[473] Fix | Delete
def update(self, dict=None, **kwargs):
[474] Fix | Delete
if dict:
[475] Fix | Delete
try:
[476] Fix | Delete
keys = dict.keys()
[477] Fix | Delete
except AttributeError:
[478] Fix | Delete
# List of (key, value)
[479] Fix | Delete
for k, v in dict:
[480] Fix | Delete
self[k] = v
[481] Fix | Delete
else:
[482] Fix | Delete
# got keys
[483] Fix | Delete
# cannot use items(), since mappings
[484] Fix | Delete
# may not have them.
[485] Fix | Delete
for k in keys:
[486] Fix | Delete
self[k] = dict[k]
[487] Fix | Delete
if kwargs:
[488] Fix | Delete
self.update(kwargs)
[489] Fix | Delete
try:
[490] Fix | Delete
unsetenv
[491] Fix | Delete
except NameError:
[492] Fix | Delete
pass
[493] Fix | Delete
else:
[494] Fix | Delete
def __delitem__(self, key):
[495] Fix | Delete
unsetenv(key)
[496] Fix | Delete
del self.data[key]
[497] Fix | Delete
def clear(self):
[498] Fix | Delete
for key in self.data.keys():
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function