Example #1
0
def proceed_iterator():
	tags = prepare_tags()
	tags_regex = prepare_tags_regex(tags)

	for i in email_interface.iterate_gmail():
		# получили письмо, и если оно не по шаблону отчёта, то обрабатываем
		if not is_report(i['lines']):
			is_processed = False
			tag = ' '
			for l in i['lines']:
				# каждую строчку отдельно: ищем сумму и таг
				# если сумма не нулевая, то мы заносим её в общий реестр
				amount = detect_numbers(l)
				new_tag = find_tag(tags, tags_regex, l)
				if tag == ' ' and new_tag is not None:
					tag = new_tag
				if amount is not None:
					is_processed = True
					yield dict(
						datetime= i['date'], #.strftime('%d.%m.%y')
						tag= tag,
						amount = amount, 
						comments = comment(i, l)
						)
			# если ни одной суммы в письме не нашли, то заносим её в дополнительный реестр
			if not is_processed:
				yield dict(
					datetime = i['date'],
					tag='', amount='',
					comments = comment(i)
					)
Example #2
0
def proceed_iterator():
    tags = prepare_tags()
    tags_regex = prepare_tags_regex(tags)

    for i in email_interface.iterate_gmail():
        # получили письмо, и если оно не по шаблону отчёта, то обрабатываем
        if not is_report(i['lines']):
            is_processed = False
            tag = ' '
            for l in i['lines']:
                # каждую строчку отдельно: ищем сумму и таг
                # если сумма не нулевая, то мы заносим её в общий реестр
                amount = detect_numbers(l)
                new_tag = find_tag(tags, tags_regex, l)
                if tag == ' ' and new_tag is not None:
                    tag = new_tag
                if amount is not None:
                    is_processed = True
                    yield dict(
                        datetime=i['date'],  #.strftime('%d.%m.%y')
                        tag=tag,
                        amount=amount,
                        comments=comment(i, l))
            # если ни одной суммы в письме не нашли, то заносим её в дополнительный реестр
            if not is_processed:
                yield dict(datetime=i['date'],
                           tag='',
                           amount='',
                           comments=comment(i))
Example #3
0
def checkout():
	for i in email_interface.iterate_gmail():
		for l in i['lines']:
			print '"%s",' % l
Example #4
0
def checkout():
    for i in email_interface.iterate_gmail():
        for l in i['lines']:
            print '"%s",' % l