Mercurial > kallithea
comparison rhodecode/lib/paster_commands/make_rcextensions.py @ 3915:a42bfe8a9335 beta
moved make-index command to paster_commands module
- optimized imports and code
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 30 May 2013 00:01:16 +0200 |
parents | f1491bad8339 |
children | ffd45b185016 |
comparison
equal
deleted
inserted
replaced
3914:424b6c711a7f | 3915:a42bfe8a9335 |
---|---|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 from __future__ import with_statement | 25 from __future__ import with_statement |
26 | 26 |
27 import os | 27 import os |
28 import sys | 28 import sys |
29 import logging | |
29 import pkg_resources | 30 import pkg_resources |
30 import traceback | |
31 import logging | |
32 | 31 |
33 from os.path import dirname as dn, join as jn | 32 from rhodecode.lib.utils import BasePasterCommand, ask_ok |
34 #to get the rhodecode import | 33 |
34 # fix rhodecode import | |
35 from os.path import dirname as dn | |
35 rc_path = dn(dn(dn(os.path.realpath(__file__)))) | 36 rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
36 sys.path.append(rc_path) | 37 sys.path.append(rc_path) |
37 | |
38 from rhodecode.lib.utils import BasePasterCommand, ask_ok | |
39 | 38 |
40 log = logging.getLogger(__name__) | 39 log = logging.getLogger(__name__) |
41 | 40 |
42 | 41 |
43 class Command(BasePasterCommand): | 42 class Command(BasePasterCommand): |
63 f.write(tmpl) | 62 f.write(tmpl) |
64 log.info('Writen new extensions file to %s' % ext_file) | 63 log.info('Writen new extensions file to %s' % ext_file) |
65 | 64 |
66 here = config['here'] | 65 here = config['here'] |
67 tmpl = pkg_resources.resource_string( | 66 tmpl = pkg_resources.resource_string( |
68 'rhodecode', jn('config', 'rcextensions', '__init__.py') | 67 'rhodecode', os.path.join('config', 'rcextensions', '__init__.py') |
69 ) | 68 ) |
70 ext_file = jn(here, 'rcextensions', '__init__.py') | 69 ext_file = os.path.join(here, 'rcextensions', '__init__.py') |
71 if os.path.exists(ext_file): | 70 if os.path.exists(ext_file): |
72 msg = ('Extension file already exists, do you want ' | 71 msg = ('Extension file already exists, do you want ' |
73 'to overwrite it ? [y/n]') | 72 'to overwrite it ? [y/n]') |
74 if ask_ok(msg): | 73 if ask_ok(msg): |
75 _make_file(ext_file, tmpl) | 74 _make_file(ext_file, tmpl) |