コード例 #1
0
def parse_simple_location(pko_operation: PkoBpOperation, o: Operation):
	regex = 'Lokalizacja: Adres: (?P<addr>.*)'
	for desc in pko_operation.descriptions:
		if m := re.match(regex, desc):
			address = m.group('addr')
			o.location = Location()
			o.location.country = ''
			o.location.city = ''
			o.location.address = address
			index = pko_operation.descriptions.index(desc)
			pko_operation.descriptions[index] = '<OK>' + desc
コード例 #2
0
def parse_full_location(pko_operation: PkoBpOperation, o: Operation):
	regex = 'Lokalizacja: Kraj: (?P<country>.*) Miasto: (?P<city>.*) Adres: (?P<addr>.*)'
	for desc in pko_operation.descriptions:
		if m := re.match(regex, desc):
			country = m.group('country')
			city = m.group('city')
			address = m.group('addr')
			o.location = Location()
			o.location.country = country
			o.location.city = city
			o.location.address = address
			index = pko_operation.descriptions.index(desc)
			pko_operation.descriptions[index] = '<OK>' + desc
コード例 #3
0
    def get_topic(self) -> topics.Topic:
        return GENERAL.EXPENSES.SPORT.BADMINTON

    def self_matches(self, operation: Operation) -> bool:
        badminton = matches_address(operation, 'KLUB BADMINTONA')
        return badminton


REGISTERED_MATCHERS: List[TopicMatcher] = []


def register(matcher: TopicMatcher):
    REGISTERED_MATCHERS.append(matcher)


register(GeneralMatcher())
register(ExpensesMatcher())
register(WorkLunchMatcher())
register(WorkFrogMatcher())
register(WorkSubwayMatcher())
register(BadmintonMatcher())

if __name__ == '__main__':
    #  quick test
    o = Operation()
    o.amount = -100.0
    o.location = Location()
    o.location.address = 'THAI WOK'
    match(o)
    print(o.topic)