MCPcopy
hub / github.com/powerline/powerline / match

Method match

powerline/lint/spec.py:689–749  ·  view source on GitHub ↗

Check that given value matches this specification :return: proceed, hadproblem.

(self, value, context_mark=None, data=None, context=(), echoerr=echoerr)

Source from the content-addressed store, hash-verified

687 return True, hadproblem
688
689 def match(self, value, context_mark=None, data=None, context=(), echoerr=echoerr):
690 '''Check that given value matches this specification
691
692 :return: proceed, hadproblem.
693 '''
694 havemarks(value)
695 proceed, hadproblem = self.match_checks(value, context_mark, data, context, echoerr)
696 if proceed:
697 if self.keys or self.uspecs:
698 for key, vali in self.keys.items():
699 valspec = self.specs[vali]
700 if key in value:
701 proceed, mhadproblem = valspec.match(
702 value[key],
703 value.mark,
704 data,
705 context.enter_key(value, key),
706 echoerr
707 )
708 if mhadproblem:
709 hadproblem = True
710 if not proceed:
711 return False, hadproblem
712 else:
713 if not valspec.isoptional:
714 hadproblem = True
715 echoerr(context=self.cmsg.format(key=context.key),
716 context_mark=None,
717 problem='required key is missing: {0}'.format(key),
718 problem_mark=value.mark)
719 for key in value.keys():
720 havemarks(key)
721 if key not in self.keys:
722 for keyfunc, vali in self.uspecs:
723 valspec = self.specs[vali]
724 if isinstance(keyfunc, int):
725 spec = self.specs[keyfunc]
726 proceed, khadproblem = spec.match(key, context_mark, data, context, echoerr)
727 else:
728 proceed, khadproblem = keyfunc(key, data, context, echoerr)
729 if khadproblem:
730 hadproblem = True
731 if proceed:
732 proceed, vhadproblem = valspec.match(
733 value[key],
734 value.mark,
735 data,
736 context.enter_key(value, key),
737 echoerr
738 )
739 if vhadproblem:
740 hadproblem = True
741 break
742 else:
743 hadproblem = True
744 if self.ufailmsg:
745 echoerr(context=self.cmsg.format(key=context.key),
746 context_mark=None,

Callers 15

create_ebuildsFunction · 0.80
checkFunction · 0.80
check_listMethod · 0.80
check_eitherMethod · 0.80
check_tupleMethod · 0.80
reMethod · 0.80
check_hl_group_nameFunction · 0.80
check_segment_functionFunction · 0.80
check_args_variantFunction · 0.80
resolveMethod · 0.80

Calls 4

match_checksMethod · 0.95
havemarksFunction · 0.90
echoerrFunction · 0.90
enter_keyMethod · 0.80

Tested by 2

test_gitMethod · 0.64
assertMatchesMethod · 0.64