Exemple #1
0
def parse_view_contents(lines):
    """ Parse view contents

    :param string paste_string: String pasted from view contents window
    """
    matches, bad_lines = regex_match_lines(VIEWCONT_LIST_RE, lines)
    matches2, bad_lines2 = regex_match_lines(STATION_CONTAINER_RE, bad_lines)

    items = defaultdict(int)
    for name, group, location, _, _, quantity in matches:
        items[(name, group, location)] += f_int(quantity)

    results = [{'name': name,
                'group': group,
                'location': location,
                'quantity': quantity}
               for (name, group, location), quantity in sorted(items.items())]

    items2 = defaultdict(int)
    for name, group, quantity in matches2:
        items2[(name, group)] += f_int(quantity)
    results2 = [{'name': name,
                 'group': group,
                 'quantity': quantity}
                for (name, group), quantity in sorted(items2.items())]

    return results + results2, bad_lines2
Exemple #2
0
def parse_contract(lines):
    """ Parse contract format

    :param string paste_string: A contract result string
    """
    matches, bad_lines = regex_match_lines(CONTRACT_RE, lines)
    matches2, bad_lines2 = regex_match_lines(CONTRACT_RE2, bad_lines)

    # Collect Items
    items = defaultdict(int)
    for name, quantity, _type, category, details in matches:
        items[(name, _type, category, details)] += f_int(quantity) or 1

    result = [{
        'name': name,
        'quantity': quantity,
        'type': _type,
        'category': category,
        'details': details,
        'fitted': details.startswith('Fitted')
    } for (name, _type, category, details), quantity in sorted(items.items())]

    # Collect Items2
    items2 = defaultdict(int)
    for name, quantity, _type in matches2:
        items2[(name, _type)] += f_int(quantity) or 1

    result2 = [{
        'name': name,
        'quantity': quantity,
        'type': _type
    } for (name, _type), quantity in items2.items()]

    return result + result2, bad_lines2
Exemple #3
0
def parse_listing(lines):
    """ Parse Listing and Cargo Scan Results

    :param string paste_string: A raw string pasted from Eve Online of a cargo
                         scan result or a human listing
    """
    matches, bad_lines = regex_match_lines(LISTING_RE, lines)
    matches2, bad_lines2 = regex_match_lines(LISTING_RE2, bad_lines)
    matches3, bad_lines3 = regex_match_lines(LISTING_RE3, bad_lines2)

    items = defaultdict(int)

    for count, name in matches:
        items[name.strip()] += f_int(count) or 1

    for name, count in matches2:
        items[name.strip()] += f_int(count) or 1

    for res in matches3:
        items[res[0].strip()] += 1

    results = []
    for name, quantity in sorted(items.items()):
        results.append({'name': name, 'quantity': quantity})

    return results, bad_lines3
Exemple #4
0
def parse_contract(lines):
    """ Parse contract format

    :param string paste_string: A contract result string
    """
    matches, bad_lines = regex_match_lines(CONTRACT_RE, lines)
    matches2, bad_lines2 = regex_match_lines(CONTRACT_RE2, bad_lines)

    # Collect Items
    items = defaultdict(int)
    for name, quantity, _type, category, details in matches:
        items[(name, _type, category, details)] += f_int(quantity) or 1

    result = [{'name': name,
               'quantity': quantity,
               'type': _type,
               'category': category,
               'details': details,
               'fitted': details.startswith('Fitted')}
              for (name, _type, category, details), quantity
              in sorted(items.items())]

    # Collect Items2
    items2 = defaultdict(int)
    for name, quantity, _type in matches2:
        items2[(name, _type)] += f_int(quantity) or 1

    result2 = [{'name': name,
               'quantity': quantity,
               'type': _type} for (name, _type), quantity in items2.items()]

    return result + result2, bad_lines2
Exemple #5
0
def parse_view_contents(lines):
    """ Parse view contents

    :param string paste_string: String pasted from view contents window
    """
    matches, bad_lines = regex_match_lines(VIEWCONT_LIST_RE, lines)
    matches2, bad_lines2 = regex_match_lines(STATION_CONTAINER_RE, bad_lines)

    items = defaultdict(int)
    for name, group, location, _, _, quantity in matches:
        items[(name, group, location)] += f_int(quantity)

    results = [{
        'name': name,
        'group': group,
        'location': location,
        'quantity': quantity
    } for (name, group, location), quantity in sorted(items.items())]

    items2 = defaultdict(int)
    for name, group, quantity in matches2:
        items2[(name, group)] += f_int(quantity)
    results2 = [{
        'name': name,
        'group': group,
        'quantity': quantity
    } for (name, group), quantity in sorted(items2.items())]

    return results + results2, bad_lines2
Exemple #6
0
def parse_listing(lines):
    """ Parse Listing and Cargo Scan Results

    :param string paste_string: A raw string pasted from Eve Online of a cargo
                         scan result or a human listing
    """
    matches, bad_lines = regex_match_lines(LISTING_RE, lines)
    matches2, bad_lines2 = regex_match_lines(LISTING_RE2, bad_lines)
    matches3, bad_lines3 = regex_match_lines(LISTING_RE3, bad_lines2)

    items = defaultdict(int)

    for count, name in matches:
        items[name.strip()] += f_int(count) or 1

    for name, count in matches2:
        items[name.strip()] += f_int(count) or 1

    for res in matches3:
        items[res[0].strip()] += 1

    results = []
    for name, quantity in sorted(items.items()):
        results.append({'name': name, 'quantity': quantity})

    return results, bad_lines3
Exemple #7
0
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)

    result = [
        {"time": time, "transaction_type": transaction_type, "amount": amount, "balance": balance, "description": desc}
        for (time, transaction_type, amount, _, balance, _, desc) in matches
    ]
    result2 = [
        {
            "time": time,
            "name": name,
            "price": price,
            "quantity": f_int(quantity),
            "credit": credit,
            "currency": currency,
            "client": client,
            "where": where,
        }
        for (time, name, price, _, quantity, credit, _, currency, client, where) in matches2
    ]

    return result + result2, bad_lines2
Exemple #8
0
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)

    result = [{
        'time': time,
        'transaction_type': transaction_type,
        'amount': amount,
        'balance': balance,
        'description': desc
    } for (time, transaction_type, amount, _, balance, _, desc) in matches]
    result2 = [{
        'time': time,
        'name': name,
        'price': price,
        'quantity': f_int(quantity),
        'credit': credit,
        'currency': currency,
        'client': client,
        'where': where
    } for (time, name, price, _, quantity, credit, _, currency, client,
           where) in matches2]

    return result + result2, bad_lines2
Exemple #9
0
def parse_assets(lines):
    """ Parse asset list

    :param string paste_string: An asset list string
    """
    matches, bad_lines = regex_match_lines(ASSET_LIST_RE, lines)

    result = [{'name': name,
               'quantity': f_int(quantity) or 1,
               'group': group,
               'category': category,
               'size': size,
               'slot': slot,
               'volume': volume,
               'meta_level': meta_level,
               'tech_level': tech_level}
              for (name,
                   quantity,
                   _, group,
                   _, category,
                   _, size,
                   _, slot,
                   _, volume,
                   _, meta_level,
                   _, tech_level) in matches]
    return result, bad_lines
Exemple #10
0
def parse_industry(lines):
    """ Parse Industry

    :param string paste_string: A raw string pasted from the industry
    """
    matches, bad_lines = regex_match_lines(INDUSTRY_RE, lines)

    items = defaultdict(int)

    for name, count in matches:
        items[name.strip()] += f_int(count)

    results = []
    for name, me, te, runs, group in sorted(items.items()):
        item = {
            'name': name,
            'me': me,
            'te': te,
            'runs': runs,
            'group': group,
        }

        results.append(item)

    return results, bad_lines
Exemple #11
0
def parse_cargo_scan(lines):
    """ Parse Cargo Scan Results

    :param string paste_string: A raw string pasted from Eve Online of a cargo
                         scan result
    """
    matches, bad_lines = regex_match_lines(CARGO_SCAN_RE, lines)

    items = defaultdict(int)

    for count, name in matches:
        items[name.strip()] += f_int(count) or 1

    results = []
    for name, quantity in sorted(items.items()):
        item = {'name': name, 'quantity': quantity}
        if item['name'].endswith(' (Copy)'):
            item['details'] = 'BLUEPRINT COPY'
            item['name'] = item['name'].replace(' (Copy)', '')
        if item['name'].endswith(' (Original)'):
            item['details'] = 'BLUEPRINT ORIGINAL'
            item['name'] = item['name'].replace(' (Original)', '')

        results.append(item)

    return results, bad_lines
Exemple #12
0
def parse_cargo_scan(lines):
    """ Parse Cargo Scan Results

    :param string paste_string: A raw string pasted from Eve Online of a cargo
                         scan result
    """
    matches, bad_lines = regex_match_lines(CARGO_SCAN_RE, lines)

    items = defaultdict(int)

    for count, name in matches:
        items[name.strip()] += f_int(count) or 1

    results = []
    for name, quantity in sorted(items.items()):
        item = {'name': name, 'quantity': quantity}
        if item['name'].endswith(' (Copy)'):
            item['details'] = 'BLUEPRINT COPY'
            item['name'] = item['name'].replace(' (Copy)', '')
        if item['name'].endswith(' (Original)'):
            item['details'] = 'BLUEPRINT ORIGINAL'
            item['name'] = item['name'].replace(' (Original)', '')

        results.append(item)

    return results, bad_lines
Exemple #13
0
def parse_assets(lines):
    """ Parse asset list

    :param string paste_string: An asset list string
    """
    matches, bad_lines = regex_match_lines(ASSET_LIST_RE, lines)

    result = [{'name': name,
               'quantity': f_int(quantity) or 1,
               'group': group,
               'category': category,
               'size': size,
               'slot': slot,
               'volume': volume,
               'meta_level': meta_level,
               'tech_level': tech_level}
              for (name,
                   quantity,
                   _, group,
                   _, category,
                   _, size,
                   _, slot,
                   _, volume,
                   _, meta_level,
                   _, tech_level) in matches]
    return result, bad_lines
def parse_bill_of_materials(lines):
    """ Parse bill of materials

    :param string paste_string: A bill of material string
    """
    matches, bad_lines = regex_match_lines(BOM_RE, lines)
    matches2, bad_lines2 = regex_match_lines(BOM_RE2, bad_lines)

    result = [{'name': name,
               'you': f_int(you),
               'perfect': f_int(perfect or you)}
              for name, you, _, perfect in matches]
    result2 = [{'name': name,
                'quantity': f_int(quantity)}
               for name, quantity in matches2]
    results = result + result2
    if results:
        for line in IGNORED_LINES:
            if line in bad_lines2:
                bad_lines2.remove(line)

    return results, bad_lines2
Exemple #15
0
def parse_loot_history(lines):
    """ Parse loot history format

    :param string paste_string: A loot history result string
    """
    matches, bad_lines = regex_match_lines(LOOT_HIST_RE, lines)

    result = [{'time': time,
               'player_name': player_name,
               'quantity': f_int(quantity),
               'name': name}
              for time, player_name, quantity, name in matches]
    return result, bad_lines
Exemple #16
0
def parse_dropped_items(lines, offset):
    for line in lines[offset:]:
        offset += 1
        match = ITEM_RE.search(line)
        if match:
            name, _, quantity, _, location = match.groups()
            yield 'dropped', {'name': name,
                              'quantity': f_int(quantity) or 1,
                              'location': location}
        else:
            raise Unparsable('Failed parsing at line %s: %s' % (offset, line))

    yield 'state_change', (None, offset)
Exemple #17
0
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)

    result = [{'name': name,
               'quantity': f_int(quantity),
               'routed': routed == 'Routed'}
              for quantity, name, routed, _ in matches]
    result2 = [{'name': name,
                'quantity': f_int(quantity),
                'volume': volume}
               for name, quantity, volume in matches2]
    result3 = [{'name': name,
                'quantity': f_int(quantity)}
               for name, quantity in matches3]

    return result + result2 + result3, bad_lines3
Exemple #18
0
def parse_loot_history(lines):
    """ Parse loot history format

    :param string paste_string: A loot history result string
    """
    matches, bad_lines = regex_match_lines(LOOT_HIST_RE, lines)

    result = [{
        'time': time,
        'player_name': player_name,
        'quantity': f_int(quantity),
        'name': name
    } for time, player_name, quantity, name in matches]
    return result, bad_lines
Exemple #19
0
def parse_survey_scanner(lines):
    """ Parse survey scanner

    :param string paste_string: A survey scanner result string
    """
    matches, bad_lines = regex_match_lines(SURVEY_SCANNER_RE, lines)

    result = [{'name': name,
               'quantity': f_int(quantity),
               'distance': distance}
              for name, quantity, distance, _ in matches]  # NOQA (F812)
    if matches:
        return result, []
    else:
        return result, bad_lines
Exemple #20
0
def parse_dropped_items(lines, offset):
    for line in lines[offset:]:
        offset += 1
        match = ITEM_RE.search(line)
        if match:
            name, _, quantity, _, location = match.groups()
            yield 'dropped', {
                'name': name,
                'quantity': f_int(quantity) or 1,
                'location': location
            }
        else:
            raise Unparsable('Failed parsing at line %s: %s' % (offset, line))

    yield 'state_change', (None, offset)
Exemple #21
0
def parse_survey_scanner(lines):
    """ Parse survey scanner

    :param string paste_string: A survey scanner result string
    """
    matches, bad_lines = regex_match_lines(SURVEY_SCANNER_RE, lines)

    result = [{
        'name': name,
        'quantity': f_int(quantity),
        'distance': distance
    } for name, quantity, distance, _ in matches]  # NOQA (F812)
    if matches:
        return result, []
    else:
        return result, bad_lines
Exemple #22
0
def parse_destroyed_items(lines, offset):
    transition = None
    for line in lines[offset:]:
        offset += 1
        transition = common_transitions(line)
        if transition:
            break

        match = ITEM_RE.search(line)
        if match:
            name, _, quantity, _, location = match.groups()
            yield 'destroyed', {'name': name,
                                'quantity': f_int(quantity) or 1,
                                'location': location}
        else:
            raise Unparsable('Failed parsing at line %s: %s' % (offset, line))

    yield 'state_change', (transition, offset)
Exemple #23
0
def parse_industry(lines):
    """ Parse Industry

    :param string paste_string: A raw string pasted from the industry
    """
    matches, bad_lines = regex_match_lines(INDUSTRY_RE, lines)

    items = defaultdict(int)

    for name, count in matches:
        items[name.strip()] += f_int(count)

    results = []
    for name, quantity in sorted(items.items()):
        item = {'name': name, 'quantity': quantity}

        results.append(item)

    return results, bad_lines
Exemple #24
0
def parse_destroyed_items(lines, offset):
    transition = None
    for line in lines[offset:]:
        offset += 1
        transition = common_transitions(line)
        if transition:
            break

        match = ITEM_RE.search(line)
        if match:
            name, _, quantity, _, location = match.groups()
            yield 'destroyed', {
                'name': name,
                'quantity': f_int(quantity) or 1,
                'location': location
            }
        else:
            raise Unparsable('Failed parsing at line %s: %s' % (offset, line))

    yield 'state_change', (transition, offset)
Exemple #25
0
def parse_chat(lines):
    """ Parse Chat transcript

    :param string paste_string: Chat transcript string
    """
    matches, bad_lines = regex_match_lines(CHAT_RE, lines)

    lines = [{'time': time, 'author': author, 'message': message}
             for _, time, author, message in matches]

    items = {}
    if lines:
        for line in lines:
            item_matches = CHAT_ITEM_RE.findall(line['message'])
            for item_id, name in item_matches:
                if item_id not in item_matches:
                    items[item_id] = {'id': f_int(item_id), 'name': name}

        return {'lines': lines, 'items': sorted(items.values())}, bad_lines
    else:
        return None, bad_lines
Exemple #26
0
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)

    result = [{'time': time,
               'transaction_type': transaction_type,
               'amount': amount,
               'balance': balance,
               'description': desc}
              for (time,
                   transaction_type,
                   amount, _,
                   balance, _,
                   desc) in matches]
    result2 = [{'time': time,
                'name': name,
                'price': price,
                'quantity': f_int(quantity),
                'credit': credit,
                'currency': currency,
                'client': client,
                'where': where}
               for (time,
                    name,
                    price, _,
                    quantity,
                    credit, _,
                    currency,
                    client,
                    where) in matches2]

    return result + result2, bad_lines2