-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src/irclog2html/irclog2html.py: add --hide-event to prevent selected … #38
base: master
Are you sure you want to change the base?
Conversation
…event types from getting emitted This can for example be used to not log join/quit messages which include domain names or IP addresses for privacy reasons with --hide-event=OTHER Closes: mgedmin#37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (other than the whitespace issue).
It would be good to have a test for this. Annoyingly, I don't currently have one for convert_irc_log()
. (Also annoyingly, the test suite was written during a time when I thought doctests were a great idea. My apologies.) I propose something like:
--- a/src/irclog2html/tests/test_irclog2html.py
+++ b/src/irclog2html/tests/test_irclog2html.py
@@ -18,6 +18,7 @@ from irclog2html.irclog2html import (
TextStyle,
XHTMLStyle,
XHTMLTableStyle,
+ convert_irc_log,
main,
parse_args,
)
@@ -709,6 +710,37 @@ def doctest_MediaWikiStyle():
"""
+class TestingStyle(AbstractStyle):
+ name = "testing"
+
+ def _servermsg(self, line):
+ print(line)
+
+ def _nicktext(self, time, nick, text, htmlcolour):
+ print(f'{nick}: {text}')
+
+
+def doctest_convert_irc_log_with_event_hiding():
+ """Test for convert_irc_log()
+
+ >>> parser = LogParser('''
+ ... 12:00 *** user1 joined #channel
+ ... 12:01 <user1> hello
+ ... 12:02 * user1 waves
+ ... 12:03 *** user1 left #channel
+ ... '''.splitlines())
+ >>> formatter = TestingStyle(sys.stdout)
+ >>> convert_irc_log(parser, formatter, title='IRC log',
+ ... prev=('Prev', None),
+ ... index=('Index', None),
+ ... next=('Next', None),
+ ... hide_events=['JOINPART'])
+ <user1> hello
+ * user1 waves
+
+ """
+
+
There's something wrong with it as written (even without the hide_events part that isn't merged yet the code doesn't print anything, I suspect I forgot how the parser expects the logs to look like), but I don't have time to debug right now.
Also, I'd love to have a short snippet about the new feature in CHANGES.rst.
help="Event to ignore and not add to the output. Can be" | ||
"one of COMMENT, ACTION, JOIN, PART, NICKCHANGE," | ||
"SERVER, OTHER. Can be given multiple times.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the output of --help
, you should notice that someword are joinedtogether.
Personally, I've decided on a rule that when splitting text across two lines, I'll put the whitespace on the next line, so it's immediately noticeable when it's missing.
help="Event to ignore and not add to the output. Can be" | |
"one of COMMENT, ACTION, JOIN, PART, NICKCHANGE," | |
"SERVER, OTHER. Can be given multiple times.") | |
help="Event to ignore and not add to the output. Can be" | |
" one of COMMENT, ACTION, JOIN, PART, NICKCHANGE," | |
" SERVER, OTHER. Can be given multiple times.") |
…event types from getting emitted
This can for example be used to not log join/quit messages which include domain names or IP addresses for privacy reasons with --hide-event=OTHER
Closes: #37