Show More
@@ -29,7 +29,7 b' from IPython.core.application import (' | |||||
29 | BaseIPythonApplication, base_flags, base_aliases |
|
29 | BaseIPythonApplication, base_flags, base_aliases | |
30 | ) |
|
30 | ) | |
31 | from IPython.core.profiledir import ProfileDir |
|
31 | from IPython.core.profiledir import ProfileDir | |
32 | from IPython.utils.path import get_ipython_dir |
|
32 | from IPython.utils.path import get_ipython_dir, get_ipython_package_dir | |
33 | from IPython.utils.traitlets import Unicode, Bool, Dict |
|
33 | from IPython.utils.traitlets import Unicode, Bool, Dict | |
34 |
|
34 | |||
35 | #----------------------------------------------------------------------------- |
|
35 | #----------------------------------------------------------------------------- | |
@@ -116,19 +116,52 b' class ProfileList(Application):' | |||||
116 | """ |
|
116 | """ | |
117 | ) |
|
117 | ) | |
118 |
|
118 | |||
119 |
def list_profile |
|
119 | def _list_profiles_in(self, path): | |
120 | # Find the search paths |
|
120 | """list profiles in a given root directory""" | |
121 | paths = [os.getcwdu(), self.ipython_dir] |
|
|||
122 |
|
||||
123 | self.log.warn('Searching for IPython profiles in paths: %r' % paths) |
|
|||
124 | for path in paths: |
|
|||
125 |
|
|
121 | files = os.listdir(path) | |
|
122 | profiles = [] | |||
126 |
|
|
123 | for f in files: | |
127 |
|
|
124 | full_path = os.path.join(path, f) | |
128 |
|
|
125 | if os.path.isdir(full_path) and f.startswith('profile_'): | |
129 |
|
|
126 | profiles.append(f.split('_',1)[-1]) | |
130 | start_cmd = 'ipython --profile=%s' % profile |
|
127 | return profiles | |
131 | print start_cmd + " ==> " + full_path |
|
128 | ||
|
129 | def _list_bundled_profiles(self): | |||
|
130 | """list profiles in a given root directory""" | |||
|
131 | path = os.path.join(get_ipython_package_dir(), u'config', u'profile') | |||
|
132 | files = os.listdir(path) | |||
|
133 | profiles = [] | |||
|
134 | for profile in files: | |||
|
135 | full_path = os.path.join(path, profile) | |||
|
136 | if os.path.isdir(full_path): | |||
|
137 | profiles.append(profile) | |||
|
138 | return profiles | |||
|
139 | ||||
|
140 | def list_profile_dirs(self): | |||
|
141 | profiles = self._list_bundled_profiles() | |||
|
142 | if profiles: | |||
|
143 | ||||
|
144 | print "Available profiles in IPython:" | |||
|
145 | for profile in profiles: | |||
|
146 | print ' ipython --profile=%s' % profile | |||
|
147 | ||||
|
148 | print " The first request for a bundled profile will copy it" | |||
|
149 | print " into your IPython directory (%s)," % self.ipython_dir | |||
|
150 | print " where you can customize it to your needs." | |||
|
151 | ||||
|
152 | profiles = self._list_profiles_in(self.ipython_dir) | |||
|
153 | if profiles: | |||
|
154 | ||||
|
155 | print "Available profiles in %s:" % self.ipython_dir | |||
|
156 | for profile in profiles: | |||
|
157 | print ' ipython --profile=%s' % profile | |||
|
158 | ||||
|
159 | profiles = self._list_profiles_in(os.getcwdu()) | |||
|
160 | if profiles: | |||
|
161 | ||||
|
162 | print "Available profiles in current directory (%s):" % os.getcwdu() | |||
|
163 | for profile in profiles: | |||
|
164 | print ' ipython --profile=%s' % profile | |||
132 |
|
165 | |||
133 | def start(self): |
|
166 | def start(self): | |
134 | self.list_profile_dirs() |
|
167 | self.list_profile_dirs() |
General Comments 0
You need to be logged in to leave comments.
Login now