Mercurial > public > src > rhodecode
comparison pylons_app/lib/utils.py @ 419:a9a607a58b1c
moved out ui_sections out of make ui function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 05 Aug 2010 01:22:33 +0200 |
parents | 55377fdc1fc6 |
children | 3bcf9529d221 |
comparison
equal
deleted
inserted
replaced
418:eda5f01de3c4 | 419:a9a607a58b1c |
---|---|
109 settings = {} | 109 settings = {} |
110 for each in ret: | 110 for each in ret: |
111 settings['hg_app_' + each.app_settings_name] = each.app_settings_value | 111 settings['hg_app_' + each.app_settings_name] = each.app_settings_value |
112 | 112 |
113 return settings | 113 return settings |
114 | 114 |
115 def make_ui(read_from='file', path=None, checkpaths=True): | 115 ui_sections = ['alias', 'auth', |
116 """ | |
117 A function that will read python rc files or database | |
118 and make an mercurial ui object from read options | |
119 | |
120 @param path: path to mercurial config file | |
121 @param checkpaths: check the path | |
122 @param read_from: read from 'file' or 'db' | |
123 """ | |
124 #propagated from mercurial documentation | |
125 sections = ['alias', 'auth', | |
126 'decode/encode', 'defaults', | 116 'decode/encode', 'defaults', |
127 'diff', 'email', | 117 'diff', 'email', |
128 'extensions', 'format', | 118 'extensions', 'format', |
129 'merge-patterns', 'merge-tools', | 119 'merge-patterns', 'merge-tools', |
130 'hooks', 'http_proxy', | 120 'hooks', 'http_proxy', |
131 'smtp', 'patch', | 121 'smtp', 'patch', |
132 'paths', 'profiling', | 122 'paths', 'profiling', |
133 'server', 'trusted', | 123 'server', 'trusted', |
134 'ui', 'web', ] | 124 'ui', 'web', ] |
125 | |
126 def make_ui(read_from='file', path=None, checkpaths=True): | |
127 """ | |
128 A function that will read python rc files or database | |
129 and make an mercurial ui object from read options | |
130 | |
131 @param path: path to mercurial config file | |
132 @param checkpaths: check the path | |
133 @param read_from: read from 'file' or 'db' | |
134 """ | |
135 #propagated from mercurial documentation | |
136 | |
135 baseui = ui.ui() | 137 baseui = ui.ui() |
136 | 138 |
137 | 139 |
138 if read_from == 'file': | 140 if read_from == 'file': |
139 if not os.path.isfile(path): | 141 if not os.path.isfile(path): |
140 log.warning('Unable to read config file %s' % path) | 142 log.warning('Unable to read config file %s' % path) |
141 return False | 143 return False |
142 | 144 |
143 cfg = config.config() | 145 cfg = config.config() |
144 cfg.read(path) | 146 cfg.read(path) |
145 for section in sections: | 147 for section in ui_sections: |
146 for k, v in cfg.items(section): | 148 for k, v in cfg.items(section): |
147 baseui.setconfig(section, k, v) | 149 baseui.setconfig(section, k, v) |
148 if checkpaths:check_repo_dir(cfg.items('paths')) | 150 if checkpaths:check_repo_dir(cfg.items('paths')) |
149 | 151 |
150 | 152 |