##// END OF EJS Templates
Modifications to profile list...
MinRK -
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 #-----------------------------------------------------------------------------
@@ -115,20 +115,53 b' class ProfileList(Application):'
115 the environment variable IPYTHON_DIR.
115 the environment variable IPYTHON_DIR.
116 """
116 """
117 )
117 )
118
118
119 def _list_profiles_in(self, path):
120 """list profiles in a given root directory"""
121 files = os.listdir(path)
122 profiles = []
123 for f in files:
124 full_path = os.path.join(path, f)
125 if os.path.isdir(full_path) and f.startswith('profile_'):
126 profiles.append(f.split('_',1)[-1])
127 return profiles
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
119 def list_profile_dirs(self):
140 def list_profile_dirs(self):
120 # Find the search paths
141 profiles = self._list_bundled_profiles()
121 paths = [os.getcwdu(), self.ipython_dir]
142 if profiles:
122
143 print
123 self.log.warn('Searching for IPython profiles in paths: %r' % paths)
144 print "Available profiles in IPython:"
124 for path in paths:
145 for profile in profiles:
125 files = os.listdir(path)
146 print ' ipython --profile=%s' % profile
126 for f in files:
147 print
127 full_path = os.path.join(path, f)
148 print " The first request for a bundled profile will copy it"
128 if os.path.isdir(full_path) and f.startswith('profile_'):
149 print " into your IPython directory (%s)," % self.ipython_dir
129 profile = f.split('_',1)[-1]
150 print " where you can customize it to your needs."
130 start_cmd = 'ipython --profile=%s' % profile
151
131 print start_cmd + " ==> " + full_path
152 profiles = self._list_profiles_in(self.ipython_dir)
153 if profiles:
154 print
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 print
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