Skip to content

Commit

Permalink
Merged with 5a8718220370
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed Feb 27, 2014
2 parents bde81b9 ef653e1 commit c0f706d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 16 deletions.
1 change: 1 addition & 0 deletions .hgtags
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
66912ff3d6c293f1e733b9c0f19dde7b5f2c1ffd 0.0.1
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
Changelog for irclogger
=======================


0.0.2 (unreleased)
------------------

- Nothing changed yet.


0.0.1 (2013-03-10)
------------------

- Initial Release
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
recursive-include irclogger *
recursive-include docs *
include *
global-exclude *.pyc
8 changes: 5 additions & 3 deletions irclogger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 4,15 @@

"""irclogger - Python IRC Logger Daemon
irclogger is a simple daemon written in the `Python Programming Language`_ utilizing the `circuits`_ framework for the sole purpose of logging a set of IRC
Channels to disk in the form that something like `irclog2html`_ can understand and parse.
irclogger is a simple daemon written in the `Python Programming Language`_
utilizing the `circuits`_ framework for the sole purpose of logging a set of
IRC Channels to disk in the form that something like `irclog2html`_ can
understand and parse.
:copyright: CopyRight (C) 2013 by James Mills
.. _Python Programming Language: http://www.python.org/
.. _circuits: http://pypi.python.org/pypi/circuits
.. _circuits: http://circuitsframework.com/
.. _irclog2html: http://pypi.python.org/pypi/irclog2html
"""

Expand Down
34 changes: 26 additions & 8 deletions irclogger/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 91,9 @@ def timestamp():


def generate_logfile(channel):
return path.join(channel, "{0:s}.log".format(strftime("%Y-%m-%d", localtime())))
return path.join(channel, "{0:s}.log".format(
strftime("%Y-%m-%d", localtime()))
)


def parse_logfile(filename):
Expand All @@ -112,7 114,9 @@ class Logger(File):
def init(self, *args, **kwargs):
super(Logger, self).init(*args, **kwargs)

interval = datetime.fromordinal((date.today() timedelta(1)).toordinal())
interval = datetime.fromordinal((
date.today() timedelta(1)
).toordinal())
Timer(interval, Rotate(), self.channel).register(self)

def rotate(self):
Expand All @@ -123,7 127,9 @@ def rotate(self):
self.fire(Close(), self.channel)
self.fire(Open(path.join(dirname, logfile), "a"), self.channel)

interval = datetime.fromordinal((date.today() timedelta(1)).toordinal())
interval = datetime.fromordinal((
date.today() timedelta(1)
).toordinal())
Timer(interval, Rotate(), self.channel).register(self)

def log(self, message):
Expand Down Expand Up @@ -160,7 166,8 @@ def init(self, host, port=6667, opts=None):
for ircchannel in self.ircchannels:
if not path.exists(path.join(opts.output, ircchannel)):
makedirs(path.join(opts.output, ircchannel))
Logger(path.join(opts.output, generate_logfile(ircchannel)), "a", channel="logger.{0:s}".format(ircchannel)).register(self)
Logger(path.join(opts.output, generate_logfile(ircchannel)), "a",
channel="logger.{0:s}".format(ircchannel)).register(self)

# Daemon?
if self.opts.daemon:
Expand Down Expand Up @@ -190,7 197,9 @@ def connected(self, host, port):

nick = self.nick
hostname = self.hostname
name = "%s on %s using circuits/%s" % (nick, hostname, circuits.__version__)
name = "{0:s} on {1:s} using circuits/{2:s}".format(
nick, hostname, circuits.__version__
)

self.fire(USER(nick, hostname, host, name))
self.fire(NICK(nick))
Expand Down Expand Up @@ -228,7 237,10 @@ def join(self, source, channel):
self.chanmap[channel].add(source[0])
self.nickmap[source[0]].add(channel)

self.fire(Log("*** {0:s} has joined {1:s}".format(source[0], channel)), "logger.{0:s}".format(channel))
self.fire(
Log("*** {0:s} has joined {1:s}".format(source[0], channel)),
"logger.{0:s}".format(channel)
)

def part(self, source, channel):
"""Part Event
Expand All @@ -240,7 252,10 @@ def part(self, source, channel):
self.chanmap[channel].remove(source[0])
self.nickmap[source[0]].remove(channel)

self.fire(Log("*** {0:s} has left {1:s}".format(source[0], channel)), "logger.{0:s}".format(channel))
self.fire(
Log("*** {0:s} has left {1:s}".format(source[0], channel)),
"logger.{0:s}".format(channel)
)

def quit(self, source, message):
"""Quit Event
Expand All @@ -251,7 266,10 @@ def quit(self, source, message):

for ircchannel in self.nickmap[source[0]]:
self.chanmap[ircchannel].remove(source[0])
self.fire(Log("*** {0:s} has quit IRC".format(source[0])), "logger.{0:s}".format(ircchannel))
self.fire(
Log("*** {0:s} has quit IRC".format(source[0])),
"logger.{0:s}".format(ircchannel)
)

del self.nickmap[source[0]]

Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 34,10 @@ def find_packages(where=".", exclude=()):
except IOError:
README = RELEASE = ""

import irclogger

setup(
name=irclogger.__name__,
version=irclogger.__version__,
description=irclogger.__doc__.split()[0],
name="irclogger",
version='0.0.2.dev0',
description="Python IRC Logger Daemon",
long_description="%s\n\n%s" % (README, RELEASE),
author="James Mills",
author_email="James Mills, prologic at shortcircuit dot net dot au",
Expand Down

0 comments on commit c0f706d

Please sign in to comment.