refactor tsstats.log.parse_log(s)

* rename tsstats.log.parse_logs to tsstats.log.parse_log and remove glob-functionality
* create tsstats.log.parse_log to handle globbing
* fix tests to use tsstats.log.parse_log instead of tsstats.log.parse_logs
* bump version to 0.4.0
This commit is contained in:
Thor77 2016-05-23 21:50:10 +02:00
parent 1f5a6211b9
commit 53ffad3d81
5 changed files with 44 additions and 44 deletions

View File

@ -54,9 +54,9 @@ author = 'Thor77'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.3' version = '0.4'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.3.0' release = '0.4.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name='tsstats', name='tsstats',
version='0.3.0', version='0.4.0',
author='Thor77', author='Thor77',
author_email='thor77@thor77.org', author_email='thor77@thor77.org',
description='A simple Teamspeak stats-generator', description='A simple Teamspeak stats-generator',

View File

@ -14,14 +14,14 @@ re_disconnect_invoker = re.compile(
logger = logging.getLogger('tsstats') logger = logging.getLogger('tsstats')
def parse_logs(log_path, ident_map=None): def parse_logs(log_glob, ident_map=None):
for log_file in sorted(log_file for log_file in glob(log_glob)):
parse_log(log_file, ident_map)
def parse_log(log_path, ident_map=None):
clients = Clients(ident_map) clients = Clients(ident_map)
log_file = open(log_path)
# find all log-files and open them TODO: move this into main
file_paths = sorted([file_path for file_path in glob(log_path)])
for file_path in file_paths:
log_file = open(file_path)
# process lines # process lines
logger.debug('Started parsing of %s', log_file.name) logger.debug('Started parsing of %s', log_file.name)
for line in log_file: for line in log_file:

View File

@ -1,12 +1,12 @@
import pytest import pytest
from tsstats.exceptions import InvalidLog from tsstats.exceptions import InvalidLog
from tsstats.log import parse_logs from tsstats.log import parse_log
@pytest.fixture @pytest.fixture
def clients(): def clients():
return parse_logs('tsstats/tests/res/test.log') return parse_log('tsstats/tests/res/test.log')
def test_log_client_count(clients): def test_log_client_count(clients):
@ -36,4 +36,4 @@ def test_log_pbans(clients):
def test_log_invalid(): def test_log_invalid():
with pytest.raises(InvalidLog): with pytest.raises(InvalidLog):
parse_logs('tsstats/tests/res/test.log.broken') parse_log('tsstats/tests/res/test.log.broken')

View File

@ -4,12 +4,12 @@ from os import remove
import pytest import pytest
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from tsstats.log import parse_logs from tsstats.log import parse_log
from tsstats.template import render_template from tsstats.template import render_template
from tsstats.utils import seconds_to_text from tsstats.utils import seconds_to_text
output_path = 'tsstats/tests/res/output.html' output_path = 'tsstats/tests/res/output.html'
clients = parse_logs('tsstats/tests/res/test.log') clients = parse_log('tsstats/tests/res/test.log')
logger = logging.getLogger('tsstats') logger = logging.getLogger('tsstats')