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,7 +241,9 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 | ||
|
245 | # use with notation for python 3.6 onward | |||
|
246 | dirlist = os.scandir(pdir) | |||
244 |
|
|
247 | for ff in dirlist: | |
245 |
|
|
248 | fname = ff.name | |
246 |
|
|
249 | base, ext = os.path.splitext(fname) |
@@ -97,7 +97,9 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 | # use with notation for python 3.6 onward | |||
|
102 | files = os.scandir(path) | |||
101 |
|
|
103 | for f in files: | |
102 |
|
|
104 | if f.is_dir() and f.name.startswith('profile_'): | |
103 |
|
|
105 | profiles.append(f.name.split('_', 1)[-1]) | |
@@ -108,7 +110,9 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 | ||
|
114 | # use with notation for python 3.6 onward | |||
|
115 | files = os.scandir(path) | |||
112 |
|
|
116 | for profile in files: | |
113 |
|
|
117 | if profile.is_dir() and profile.name != "__pycache__": | |
114 |
|
|
118 | profiles.append(profile.name) |
General Comments 0
You need to be logged in to leave comments.
Login now