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