# Path: evepaste/utils.py
# def regex_match_lines(regex, lines):
#     """
#     Performs a regex search on each line and returns a list of matched groups
#     and a list of lines which didn't match.
# 
#     :param regex regex: String to be split and stripped
#     :param list lines: A list of strings to perform the regex on.
#     """
#     matches = []
#     bad_lines = []
#     for line in lines:
#         match = regex.search(line)
#         if match:
#             matches.append(match.groups())
#         else:
#             bad_lines.append(line)
#     return matches, bad_lines
# 
# def f_int(num):
#     """ Converts a given numeric string into an integer
# 
#     :param string num: A string of the format "123,456", "123'456", "123 456"
#                     or "123456"
#     """
#     if num is None:
#         return
#     try:
#         return int(sub(r"[,'\. ']", '', num))
# 
#     except ValueError:
#         return 0


import re
from evepaste.utils import regex_match_lines, f_int
~~~~~~~~~~~~~~~~~~~~~~~
Parse wallet results.

"""


JOURNAL_RE = re.compile(r"""^(\d\d\d\d.\d\d.\d\d\ \d\d:\d\d:\d\d)\t  # time
                             ([\S ]+)\t                # transaction type
                             ([-\d,'\.]+\ (ISK|AUR))\t # amount
                             ([\d,'\.]+\ (ISK|AUR))\t  # balance
                             ([\S ]*)$                 # description
                         """, re.X)

TRANSACTION_RE = re.compile(r"""^(\d\d\d\d.\d\d.\d\d\ \d\d:\d\d)\t  # when
                             ([\S ]+)\t                # name
                             ([\d,'\.]+\ (ISK|AUR))\t  # price
                             ([\d,'\.]+)\t             # quantity
                             ([-\d,'\.]+\ (ISK|AUR))\t # credit
                             (ISK|AUR)\t               # currency
                             ([\S ]+)\t                # client
                             ([\S ]+)$                 # where
                         """, re.X)


def parse_wallet(lines):
    """ Parse wallet

    :param string paste_string: A swallet result string
    """
    matches, bad_lines = regex_match_lines(JOURNAL_RE, lines)

# Path: evepaste/utils.py
# def regex_match_lines(regex, lines):
#     """
#     Performs a regex search on each line and returns a list of matched groups
#     and a list of lines which didn't match.
# 
#     :param regex regex: String to be split and stripped
#     :param list lines: A list of strings to perform the regex on.
#     """
#     matches = []
#     bad_lines = []
#     for line in lines:
#         match = regex.search(line)
#         if match:
#             matches.append(match.groups())
#         else:
#             bad_lines.append(line)
#     return matches, bad_lines
# 
# def f_int(num):
#     """ Converts a given numeric string into an integer
# 
#     :param string num: A string of the format "123,456", "123'456", "123 456"
#                     or "123456"
#     """
#     if num is None:
#         return
#     try:
#         return int(sub(r"[,'\. ']", '', num))
# 
#     except ValueError:
#         return 0


# Path: evepaste/parsers/wallet.py
import re
from evepaste.utils import regex_match_lines, f_int

~~~~~~~~~~~~~~~~~~~~~~~
Parse wallet results.

"""


JOURNAL_RE = re.compile(r"""^(\d\d\d\d.\d\d.\d\d\ \d\d:\d\d:\d\d)\t  # time
                             ([\S ]+)\t                # transaction type
                             ([-\d,'\.]+\ (ISK|AUR))\t # amount
                             ([\d,'\.]+\ (ISK|AUR))\t  # balance
                             ([\S ]*)$                 # description
                         """, re.X)

TRANSACTION_RE = re.compile(r"""^(\d\d\d\d.\d\d.\d\d\ \d\d:\d\d)\t  # when
                             ([\S ]+)\t                # name
                             ([\d,'\.]+\ (ISK|AUR))\t  # price
                             ([\d,'\.]+)\t             # quantity
                             ([-\d,'\.]+\ (ISK|AUR))\t # credit
                             (ISK|AUR)\t               # currency
                             ([\S ]+)\t                # client
                             ([\S ]+)$                 # where
                         """, re.X)


def parse_wallet(lines):
    """ Parse wallet

    :param string paste_string: A swallet result string
    """
    matches, bad_lines = regex_match_lines(JOURNAL_RE, lines)

    matches2, bad_lines2 = regex_match_lines(TRANSACTION_RE, bad_lines)