@@ -107,7 +107,7 @@ def dup2(self, fd):
107107 return posix .fdopen (fd , self ._file_ .mode )
108108
109109 def flags (self , * which ):
110- import fcntl , FCNTL
110+ import fcntl
111111
112112 if which :
113113 if len (which ) > 1 :
@@ -116,44 +116,44 @@ def flags(self, *which):
116116 else : which = '?'
117117
118118 l_flags = 0
119- if 'n' in which : l_flags = l_flags | FCNTL .O_NDELAY
120- if 'a' in which : l_flags = l_flags | FCNTL .O_APPEND
121- if 's' in which : l_flags = l_flags | FCNTL .O_SYNC
119+ if 'n' in which : l_flags = l_flags | os .O_NDELAY
120+ if 'a' in which : l_flags = l_flags | os .O_APPEND
121+ if 's' in which : l_flags = l_flags | os .O_SYNC
122122
123123 file = self ._file_
124124
125125 if '=' not in which :
126- cur_fl = fcntl .fcntl (file .fileno (), FCNTL .F_GETFL , 0 )
126+ cur_fl = fcntl .fcntl (file .fileno (), fcntl .F_GETFL , 0 )
127127 if '!' in which : l_flags = cur_fl & ~ l_flags
128128 else : l_flags = cur_fl | l_flags
129129
130- l_flags = fcntl .fcntl (file .fileno (), FCNTL .F_SETFL , l_flags )
130+ l_flags = fcntl .fcntl (file .fileno (), fcntl .F_SETFL , l_flags )
131131
132132 if 'c' in which :
133133 arg = ('!' not in which ) # 0 is don't, 1 is do close on exec
134- l_flags = fcntl .fcntl (file .fileno (), FCNTL .F_SETFD , arg )
134+ l_flags = fcntl .fcntl (file .fileno (), fcntl .F_SETFD , arg )
135135
136136 if '?' in which :
137137 which = '' # Return current flags
138- l_flags = fcntl .fcntl (file .fileno (), FCNTL .F_GETFL , 0 )
139- if FCNTL .O_APPEND & l_flags : which = which + 'a'
140- if fcntl .fcntl (file .fileno (), FCNTL .F_GETFD , 0 ) & 1 :
138+ l_flags = fcntl .fcntl (file .fileno (), fcntl .F_GETFL , 0 )
139+ if os .O_APPEND & l_flags : which = which + 'a'
140+ if fcntl .fcntl (file .fileno (), fcntl .F_GETFD , 0 ) & 1 :
141141 which = which + 'c'
142- if FCNTL .O_NDELAY & l_flags : which = which + 'n'
143- if FCNTL .O_SYNC & l_flags : which = which + 's'
142+ if os .O_NDELAY & l_flags : which = which + 'n'
143+ if os .O_SYNC & l_flags : which = which + 's'
144144 return which
145145
146146 def lock (self , how , * args ):
147- import struct , fcntl , FCNTL
147+ import struct , fcntl
148148
149- if 'w' in how : l_type = FCNTL .F_WRLCK
150- elif 'r' in how : l_type = FCNTL .F_RDLCK
151- elif 'u' in how : l_type = FCNTL .F_UNLCK
149+ if 'w' in how : l_type = fcntl .F_WRLCK
150+ elif 'r' in how : l_type = fcntl .F_RDLCK
151+ elif 'u' in how : l_type = fcntl .F_UNLCK
152152 else : raise TypeError , 'no type of lock specified'
153153
154- if '|' in how : cmd = FCNTL .F_SETLKW
155- elif '?' in how : cmd = FCNTL .F_GETLK
156- else : cmd = FCNTL .F_SETLK
154+ if '|' in how : cmd = fcntl .F_SETLKW
155+ elif '?' in how : cmd = fcntl .F_GETLK
156+ else : cmd = fcntl .F_SETLK
157157
158158 l_whence = 0
159159 l_start = 0
@@ -203,8 +203,8 @@ def lock(self, how, *args):
203203 l_type , l_whence , l_start , l_len , l_sysid , l_pid = \
204204 struct .unpack ('hhllhh' , flock )
205205
206- if l_type != FCNTL .F_UNLCK :
207- if l_type == FCNTL .F_RDLCK :
206+ if l_type != fcntl .F_UNLCK :
207+ if l_type == fcntl .F_RDLCK :
208208 return 'r' , l_len , l_start , l_whence , l_pid
209209 else :
210210 return 'w' , l_len , l_start , l_whence , l_pid
0 commit comments