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