Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Parse events from log produced by dedicated server of «IL-2 Forgotten Battles» flight simulator

Project Description

Table of contents

Synopsis

This is a Python library which parses events from log produced by dedicated server of «IL-2 Forgotten Battles» flight simulator. Resulting information about events is stored in special data structures.

Demo

You may see this library in action even if you do not understand its purpose.

All you need is just to visit project’s demo page.

That page allows you to test parser’s ability to process strings. If you do not know what to enter into a text area, you may click Insert test data and parse it.

If something goes wrong, you will be prompted to confirm automatic creation of bug report which will be listed on this page.

Known events

This library supports all known events produced by dedicated server (129 unique events).

To see their list, go to the demo page and click See the list of supported events link.

Installation

Get Python package from PyPI:

pip install il2fb-events-parser

Usage

If you need to be able to parse all events this library knows about, use EventsParser.parse_string():

Import EventsParser and create its instance:

from il2fb.parsers.events import EventsParser

parser = EventsParser()

Parse a string to get an instance of event:

event = parser.parse("[8:33:05 PM] User0 has connected")

Explore event’s internal structure:

print(event)
# <Event: HumanHasConnected>

print(event.time)
# datetime.time(20, 33, 5)

print(event.actor)
# <Human 'User0'>

print(event.actor.callsign)
# User0

Convert event into a dictionary:

import pprint

pprint.pprint(event.to_primitive())
# {'actor': {'callsign': 'User0'},
#  'name': 'HumanHasConnected',
#  'time': '20:33:05',
#  'verbose_name': 'Human has connected'}

Exceptions

If you try to parse unknown event, EventParsingError will be raised:

parser.parse("foo bar")
# Traceback (most recent call last):
# …
# EventParsingError: No event was found for string "foo bar"

Current list of supported events is rather full, but EventParsingError is quite possible, because server’s events are undocumented and this library may do not know about all of them.

In case you need to catch this error, its full name is il2fb.parsers.events.exceptions.EventParsingError.

Safe usage

You can set flag ignore_errors=True if you don’t care about any exceptions:

from il2fb.parsers.events import EventsParser

parser = EventsParser()
event = parser.parse("foo bar", ignore_errors=True)
print(event is None)
# True

Any error (except SystemExit and KeyboardInterrupt) will be muted and None will be returned.

Release History

Release History

This version
History Node

1.0.1

History Node

0.11.0

History Node

0.10.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
il2fb-events-parser-1.0.1.tar.gz (23.9 kB) Copy SHA256 Checksum SHA256 Source Jul 16, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting