# 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


import re
from evepaste.utils import regex_match_lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parse planetary interaction results.

"""


PI_RE = re.compile(r"""^([\d,'\.]+)\t            # quantity
                        ([\S ]+)\t               # name
                        ((Routed|Not\ routed))$  # routed
                    """, re.X)

PI_RE2 = re.compile(r"""^\t             # icon
                         ([\S ]+)\t     # name
                         ([\d,'\.]+)\t  # quantity
                         ([\d,'\.]+)$   # volume
                     """, re.X)

PI_RE3 = re.compile(r"""^\t            # icon
                         ([\S ]+)\t    # name
                         ([\d,'\.]+)$  # quantity
                     """, re.X)


def parse_pi(lines):
    """ Parse planetary interaction results

    :param string paste_string: A PI result string
    """
    matches, bad_lines = regex_match_lines(PI_RE, lines)
    matches2, bad_lines2 = regex_match_lines(PI_RE2, bad_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


# Path: evepaste/parsers/pi.py
import re
from evepaste.utils import regex_match_lines

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parse planetary interaction results.

"""


PI_RE = re.compile(r"""^([\d,'\.]+)\t            # quantity
                        ([\S ]+)\t               # name
                        ((Routed|Not\ routed))$  # routed
                    """, re.X)

PI_RE2 = re.compile(r"""^\t             # icon
                         ([\S ]+)\t     # name
                         ([\d,'\.]+)\t  # quantity
                         ([\d,'\.]+)$   # volume
                     """, re.X)

PI_RE3 = re.compile(r"""^\t            # icon
                         ([\S ]+)\t    # name
                         ([\d,'\.]+)$  # quantity
                     """, re.X)


def parse_pi(lines):
    """ Parse planetary interaction results

    :param string paste_string: A PI result string
    """
    matches, bad_lines = regex_match_lines(PI_RE, lines)
    matches2, bad_lines2 = regex_match_lines(PI_RE2, bad_lines)

    matches3, bad_lines3 = regex_match_lines(PI_RE3, bad_lines2)