Mercurial > september
comparison september.py @ 5:9c6605b1619b draft default tip
Make directories absolute and expand tilde-paths.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 12 May 2015 23:55:27 -0700 |
parents | bdfc8a4a335d |
children |
comparison
equal
deleted
inserted
replaced
4:bdfc8a4a335d | 5:9c6605b1619b |
---|---|
137 help="See September's status for the given repository.") | 137 help="See September's status for the given repository.") |
138 | 138 |
139 # Parse arguments. | 139 # Parse arguments. |
140 res = parser.parse_args() | 140 res = parser.parse_args() |
141 repo_dir = res.repo or os.getcwd() | 141 repo_dir = res.repo or os.getcwd() |
142 repo_dir = os.path.abspath(repo_dir) | |
142 work_dir = os.getcwd() | 143 work_dir = os.getcwd() |
143 | 144 |
144 # Guess the repo type. | 145 # Guess the repo type. |
145 repo_type = res.scm | 146 repo_type = res.scm |
146 if not repo_type or repo_type == 'guess': | 147 if not repo_type or repo_type == 'guess': |
154 sys.exit(1) | 155 sys.exit(1) |
155 | 156 |
156 # Find the configuration file. | 157 # Find the configuration file. |
157 config_file_dir = None | 158 config_file_dir = None |
158 config_file = res.config or os.path.join(repo_dir, '.september.cfg') | 159 config_file = res.config or os.path.join(repo_dir, '.september.cfg') |
160 config_file = os.path.abspath(config_file) | |
159 config = configparser.ConfigParser(interpolation=None) | 161 config = configparser.ConfigParser(interpolation=None) |
160 if os.path.exists(config_file): | 162 if os.path.exists(config_file): |
161 logger.info("Loading configuration file: %s" % config_file) | 163 logger.info("Loading configuration file: %s" % config_file) |
162 config.read(config_file) | 164 config.read(config_file) |
163 config_file_dir = os.path.dirname(config_file) | 165 config_file_dir = os.path.dirname(config_file) |
181 tmp_dir = config_sec.get('tmp_dir', None) | 183 tmp_dir = config_sec.get('tmp_dir', None) |
182 if not tmp_dir: | 184 if not tmp_dir: |
183 tmp_name = 'september_%s' % hashlib.md5( | 185 tmp_name = 'september_%s' % hashlib.md5( |
184 repo_dir.encode('utf8')).hexdigest() | 186 repo_dir.encode('utf8')).hexdigest() |
185 tmp_dir = os.path.join(tempfile.gettempdir(), tmp_name) | 187 tmp_dir = os.path.join(tempfile.gettempdir(), tmp_name) |
188 elif tmp_dir.startswith('~'): | |
189 tmp_dir = os.path.expanduser(tmp_dir) | |
186 | 190 |
187 # Find the cache file in the temp directory. | 191 # Find the cache file in the temp directory. |
188 cache_file = os.path.join(tmp_dir, 'september.json') | 192 cache_file = os.path.join(tmp_dir, 'september.json') |
189 if os.path.exists(cache_file): | 193 if os.path.exists(cache_file): |
190 with open(cache_file, 'r') as fp: | 194 with open(cache_file, 'r') as fp: |