##// END OF EJS Templates
ui: refactor `readconfig()` into a form that can consume resources...
Matt Harbison -
r44482:5ac0e6f1 default
parent child Browse files
Show More
@@ -45,6 +45,7 b' from . import ('
45 from .utils import (
45 from .utils import (
46 dateutil,
46 dateutil,
47 procutil,
47 procutil,
48 resourceutil,
48 stringutil,
49 stringutil,
49 )
50 )
50
51
@@ -424,6 +425,20 b' class ui(object):'
424 )
425 )
425 return False
426 return False
426
427
428 def read_resource_config(
429 self, name, root=None, trust=False, sections=None, remap=None
430 ):
431 try:
432 fp = resourceutil.open_resource(name[0], name[1])
433 except IOError:
434 if not sections: # ignore unless we were looking for something
435 return
436 raise
437
438 self._readconfig(
439 b'resource:%s.%s' % name, fp, root, trust, sections, remap
440 )
441
427 def readconfig(
442 def readconfig(
428 self, filename, root=None, trust=False, sections=None, remap=None
443 self, filename, root=None, trust=False, sections=None, remap=None
429 ):
444 ):
@@ -434,6 +449,11 b' class ui(object):'
434 return
449 return
435 raise
450 raise
436
451
452 self._readconfig(filename, fp, root, trust, sections, remap)
453
454 def _readconfig(
455 self, filename, fp, root=None, trust=False, sections=None, remap=None
456 ):
437 with fp:
457 with fp:
438 cfg = config.config()
458 cfg = config.config()
439 trusted = sections or trust or self._trusted(fp, filename)
459 trusted = sections or trust or self._trusted(fp, filename)
General Comments 0
You need to be logged in to leave comments. Login now