##// END OF EJS Templates
templater: remove unused context argument from most resourcemapper functions...
Yuya Nishihara -
r39618:28f974d8 default
parent child Browse files
Show More
@@ -548,18 +548,18 b' class templateresources(templater.resour'
548 'ui': ui,
548 'ui': ui,
549 }
549 }
550
550
551 def availablekeys(self, context, mapping):
551 def availablekeys(self, mapping):
552 return {k for k, g in self._gettermap.iteritems()
552 return {k for k, g in self._gettermap.iteritems()
553 if g(self, context, mapping, k) is not None}
553 if g(self, mapping, k) is not None}
554
554
555 def knownkeys(self):
555 def knownkeys(self):
556 return self._knownkeys
556 return self._knownkeys
557
557
558 def lookup(self, context, mapping, key):
558 def lookup(self, mapping, key):
559 get = self._gettermap.get(key)
559 get = self._gettermap.get(key)
560 if not get:
560 if not get:
561 return None
561 return None
562 return get(self, context, mapping, key)
562 return get(self, mapping, key)
563
563
564 def populatemap(self, context, origmapping, newmapping):
564 def populatemap(self, context, origmapping, newmapping):
565 mapping = {}
565 mapping = {}
@@ -571,7 +571,7 b' class templateresources(templater.resour'
571 mapping['originalnode'] = orignode
571 mapping['originalnode'] = orignode
572 return mapping
572 return mapping
573
573
574 def _getsome(self, context, mapping, key):
574 def _getsome(self, mapping, key):
575 v = mapping.get(key)
575 v = mapping.get(key)
576 if v is not None:
576 if v is not None:
577 return v
577 return v
@@ -580,7 +580,7 b' class templateresources(templater.resour'
580 def _hasctx(self, mapping):
580 def _hasctx(self, mapping):
581 return 'ctx' in mapping or 'fctx' in mapping
581 return 'ctx' in mapping or 'fctx' in mapping
582
582
583 def _getctx(self, context, mapping, key):
583 def _getctx(self, mapping, key):
584 ctx = mapping.get('ctx')
584 ctx = mapping.get('ctx')
585 if ctx is not None:
585 if ctx is not None:
586 return ctx
586 return ctx
@@ -588,11 +588,11 b' class templateresources(templater.resour'
588 if fctx is not None:
588 if fctx is not None:
589 return fctx.changectx()
589 return fctx.changectx()
590
590
591 def _getrepo(self, context, mapping, key):
591 def _getrepo(self, mapping, key):
592 ctx = self._getctx(context, mapping, 'ctx')
592 ctx = self._getctx(mapping, 'ctx')
593 if ctx is not None:
593 if ctx is not None:
594 return ctx.repo()
594 return ctx.repo()
595 return self._getsome(context, mapping, key)
595 return self._getsome(mapping, key)
596
596
597 _gettermap = {
597 _gettermap = {
598 'cache': _getsome,
598 'cache': _getsome,
@@ -548,7 +548,7 b' class resourcemapper(object):'
548 __metaclass__ = abc.ABCMeta
548 __metaclass__ = abc.ABCMeta
549
549
550 @abc.abstractmethod
550 @abc.abstractmethod
551 def availablekeys(self, context, mapping):
551 def availablekeys(self, mapping):
552 """Return a set of available resource keys based on the given mapping"""
552 """Return a set of available resource keys based on the given mapping"""
553
553
554 @abc.abstractmethod
554 @abc.abstractmethod
@@ -556,7 +556,7 b' class resourcemapper(object):'
556 """Return a set of supported resource keys"""
556 """Return a set of supported resource keys"""
557
557
558 @abc.abstractmethod
558 @abc.abstractmethod
559 def lookup(self, context, mapping, key):
559 def lookup(self, mapping, key):
560 """Return a resource for the key if available; otherwise None"""
560 """Return a resource for the key if available; otherwise None"""
561
561
562 @abc.abstractmethod
562 @abc.abstractmethod
@@ -565,13 +565,13 b' class resourcemapper(object):'
565 with the given new mapping"""
565 with the given new mapping"""
566
566
567 class nullresourcemapper(resourcemapper):
567 class nullresourcemapper(resourcemapper):
568 def availablekeys(self, context, mapping):
568 def availablekeys(self, mapping):
569 return set()
569 return set()
570
570
571 def knownkeys(self):
571 def knownkeys(self):
572 return set()
572 return set()
573
573
574 def lookup(self, context, mapping, key):
574 def lookup(self, mapping, key):
575 return None
575 return None
576
576
577 def populatemap(self, context, origmapping, newmapping):
577 def populatemap(self, context, origmapping, newmapping):
@@ -618,7 +618,7 b' class engine(object):'
618 # do not copy symbols which overrides the defaults depending on
618 # do not copy symbols which overrides the defaults depending on
619 # new resources, so the defaults will be re-evaluated (issue5612)
619 # new resources, so the defaults will be re-evaluated (issue5612)
620 knownres = self._resources.knownkeys()
620 knownres = self._resources.knownkeys()
621 newres = self._resources.availablekeys(self, newmapping)
621 newres = self._resources.availablekeys(newmapping)
622 mapping = {k: v for k, v in origmapping.iteritems()
622 mapping = {k: v for k, v in origmapping.iteritems()
623 if (k in knownres # not a symbol per self.symbol()
623 if (k in knownres # not a symbol per self.symbol()
624 or newres.isdisjoint(self._defaultrequires(k)))}
624 or newres.isdisjoint(self._defaultrequires(k)))}
@@ -645,7 +645,7 b' class engine(object):'
645
645
646 def availableresourcekeys(self, mapping):
646 def availableresourcekeys(self, mapping):
647 """Return a set of available resource keys based on the given mapping"""
647 """Return a set of available resource keys based on the given mapping"""
648 return self._resources.availablekeys(self, mapping)
648 return self._resources.availablekeys(mapping)
649
649
650 def knownresourcekeys(self):
650 def knownresourcekeys(self):
651 """Return a set of supported resource keys"""
651 """Return a set of supported resource keys"""
@@ -654,7 +654,7 b' class engine(object):'
654 def resource(self, mapping, key):
654 def resource(self, mapping, key):
655 """Return internal data (e.g. cache) used for keyword/function
655 """Return internal data (e.g. cache) used for keyword/function
656 evaluation"""
656 evaluation"""
657 v = self._resources.lookup(self, mapping, key)
657 v = self._resources.lookup(mapping, key)
658 if v is None:
658 if v is None:
659 raise templateutil.ResourceUnavailable(
659 raise templateutil.ResourceUnavailable(
660 _('template resource not available: %s') % key)
660 _('template resource not available: %s') % key)
@@ -856,7 +856,7 b' def runsymbol(context, mapping, key, def'
856 # old templatekw: expand all keywords and resources
856 # old templatekw: expand all keywords and resources
857 # (TODO: drop support for old-style functions. 'f._requires = ()'
857 # (TODO: drop support for old-style functions. 'f._requires = ()'
858 # can be removed.)
858 # can be removed.)
859 props = {k: context._resources.lookup(context, mapping, k)
859 props = {k: context._resources.lookup(mapping, k)
860 for k in context._resources.knownkeys()}
860 for k in context._resources.knownkeys()}
861 # pass context to _showcompatlist() through templatekw._showlist()
861 # pass context to _showcompatlist() through templatekw._showlist()
862 props['templ'] = context
862 props['templ'] = context
General Comments 0
You need to be logged in to leave comments. Login now