##// END OF EJS Templates
removed with notation. This is not supported by python 3.5
kd2718 -
Show More
@@ -218,8 +218,9 b' class OSMagics(Magics):'
218 os.chdir(pdir)
218 os.chdir(pdir)
219 except OSError:
219 except OSError:
220 continue
220 continue
221
222 # use with notation for python 3.6 onward
221 dirlist = os.scandir(path=pdir)
223 dirlist = os.scandir(path=pdir)
222 #with os.scandir(pdir) as dirlist:
223 for ff in dirlist:
224 for ff in dirlist:
224 if self.isexec(ff):
225 if self.isexec(ff):
225 fname = ff.name
226 fname = ff.name
@@ -240,21 +241,23 b' class OSMagics(Magics):'
240 os.chdir(pdir)
241 os.chdir(pdir)
241 except OSError:
242 except OSError:
242 continue
243 continue
243 with os.scandir(pdir) as dirlist:
244
244 for ff in dirlist:
245 # use with notation for python 3.6 onward
245 fname = ff.name
246 dirlist = os.scandir(pdir)
246 base, ext = os.path.splitext(fname)
247 for ff in dirlist:
247 if self.isexec(ff) and base.lower() not in no_alias:
248 fname = ff.name
248 if ext.lower() == '.exe':
249 base, ext = os.path.splitext(fname)
249 fname = base
250 if self.isexec(ff) and base.lower() not in no_alias:
250 try:
251 if ext.lower() == '.exe':
251 # Removes dots from the name since ipython
252 fname = base
252 # will assume names with dots to be python.
253 try:
253 self.shell.alias_manager.define_alias(
254 # Removes dots from the name since ipython
254 base.lower().replace('.',''), fname)
255 # will assume names with dots to be python.
255 except InvalidAliasError:
256 self.shell.alias_manager.define_alias(
256 pass
257 base.lower().replace('.',''), fname)
257 syscmdlist.append(fname)
258 except InvalidAliasError:
259 pass
260 syscmdlist.append(fname)
258 self.shell.db['syscmdlist'] = syscmdlist
261 self.shell.db['syscmdlist'] = syscmdlist
259 finally:
262 finally:
260 os.chdir(savedir)
263 os.chdir(savedir)
@@ -97,10 +97,12 b" ipython locate profile foo # print the path to the directory for profile 'foo'"
97 def list_profiles_in(path):
97 def list_profiles_in(path):
98 """list profiles in a given root directory"""
98 """list profiles in a given root directory"""
99 profiles = []
99 profiles = []
100 with os.scandir(path) as files:
100
101 for f in files:
101 # use with notation for python 3.6 onward
102 if f.is_dir() and f.name.startswith('profile_'):
102 files = os.scandir(path)
103 profiles.append(f.name.split('_', 1)[-1])
103 for f in files:
104 if f.is_dir() and f.name.startswith('profile_'):
105 profiles.append(f.name.split('_', 1)[-1])
104 return profiles
106 return profiles
105
107
106
108
@@ -108,10 +110,12 b' def list_bundled_profiles():'
108 """list profiles that are bundled with IPython."""
110 """list profiles that are bundled with IPython."""
109 path = os.path.join(get_ipython_package_dir(), u'core', u'profile')
111 path = os.path.join(get_ipython_package_dir(), u'core', u'profile')
110 profiles = []
112 profiles = []
111 with os.scandir(path) as files:
113
112 for profile in files:
114 # use with notation for python 3.6 onward
113 if profile.is_dir() and profile.name != "__pycache__":
115 files = os.scandir(path)
114 profiles.append(profile.name)
116 for profile in files:
117 if profile.is_dir() and profile.name != "__pycache__":
118 profiles.append(profile.name)
115 return profiles
119 return profiles
116
120
117
121
General Comments 0
You need to be logged in to leave comments. Login now