eric6/DebugClients/Python/DebugUtilities.py

changeset 7892
bd6b9e401166
parent 7873
cb2badbdf26c
child 7895
554fdb07c856
equal deleted inserted replaced
7891:7314fdc2f8be 7892:bd6b9e401166
186 @type str 186 @type str
187 @return flag indicating an existing and valid shebang line 187 @return flag indicating an existing and valid shebang line
188 @rtype bool 188 @rtype bool
189 """ 189 """
190 try: 190 try:
191 with open(program) as f: 191 if os.path.exists(program):
192 for line in f: 192 with open(program) as f:
193 line = line.strip() 193 for line in f:
194 if line: 194 line = line.strip()
195 for name in PYTHON_NAMES: 195 if line:
196 if line.startswith('#!/usr/bin/env {0}'.format(name)): 196 for name in PYTHON_NAMES:
197 return True 197 if line.startswith(
198 elif line.startswith('#!') and name in line: 198 '#!/usr/bin/env {0}'.format(name)
199 return True 199 ):
200 return False 200 return True
201 elif line.startswith('#!') and name in line:
202 return True
203 return False
204 else:
205 return False
201 except UnicodeDecodeError: 206 except UnicodeDecodeError:
202 return False 207 return False
203 except Exception: 208 except Exception:
204 traceback.print_exc() 209 traceback.print_exc()
205 return False 210 return False

eric ide

mercurial