File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858
5959# try and find the group file
6060__group_path = []
61- if os . environ . has_key ( 'ETC_GROUP' ) :
61+ if 'ETC_GROUP' in os . environ :
6262 __group_path .append (os .environ ['ETC_GROUP' ])
63- if os . environ . has_key ( 'ETC' ) :
63+ if 'ETC' in os . environ :
6464 __group_path .append ('%s/group' % os .environ ['ETC' ])
65- if os . environ . has_key ( 'PYTHONHOME' ) :
65+ if 'PYTHONHOME' in os . environ :
6666 __group_path .append ('%s/Etc/group' % os .environ ['PYTHONHOME' ])
6767
6868group_file = None
@@ -149,9 +149,9 @@ def __read_group_file():
149149 fields [2 ] = int (fields [2 ])
150150 fields [3 ] = [f .strip () for f in fields [3 ].split (',' )]
151151 record = Group (* fields )
152- if not gidx . has_key ( fields [2 ]) :
152+ if fields [2 ] not in gidx :
153153 gidx [fields [2 ]] = record
154- if not namx . has_key ( fields [0 ]) :
154+ if fields [0 ] not in namx :
155155 namx [fields [0 ]] = record
156156 elif len (entry ) > 0 :
157157 pass # skip empty or malformed records
Original file line number Diff line number Diff line change 6161
6262# try and find the passwd file
6363__passwd_path = []
64- if os . environ . has_key ( 'ETC_PASSWD' ) :
64+ if 'ETC_PASSWD' in os . environ :
6565 __passwd_path .append (os .environ ['ETC_PASSWD' ])
66- if os . environ . has_key ( 'ETC' ) :
66+ if 'ETC' in os . environ :
6767 __passwd_path .append ('%s/passwd' % os .environ ['ETC' ])
68- if os . environ . has_key ( 'PYTHONHOME' ) :
68+ if 'PYTHONHOME' in os . environ :
6969 __passwd_path .append ('%s/Etc/passwd' % os .environ ['PYTHONHOME' ])
7070
7171passwd_file = None
@@ -164,7 +164,7 @@ def __read_passwd_file():
164164 uidx = {}
165165 namx = {}
166166 sep = None
167- while 1 :
167+ while True :
168168 entry = passwd .readline ().strip ()
169169 if len (entry ) > 6 :
170170 if sep == None :
@@ -175,9 +175,9 @@ def __read_passwd_file():
175175 for i in (5 , 6 ):
176176 fields [i ] = __field_sep [sep ](fields [i ])
177177 record = Passwd (* fields )
178- if not uidx . has_key ( fields [2 ]) :
178+ if fields [2 ] not in uidx :
179179 uidx [fields [2 ]] = record
180- if not namx . has_key ( fields [0 ]) :
180+ if fields [0 ] not in namx :
181181 namx [fields [0 ]] = record
182182 elif len (entry ) > 0 :
183183 pass # skip empty or malformed records
You can’t perform that action at this time.
0 commit comments