Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/irclog2html/irclog2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ def parse_args(argv=sys.argv):
parser.add_option('-o', '--output-file',
help="destination output file or directory"
" (default: <input-file-name>.html)")
parser.add_option('--hide-event', dest="hide_events", action='append',
choices=['COMMENT', 'ACTION', 'JOIN', 'PART',
'NICKCHANGE', 'SERVER', 'OTHER'], default=[],
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.")
Comment on lines +881 to +883
Copy link
Owner

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.

Suggested change
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.")

for name, default, what in COLOURS:
parser.add_option('--color-%s' % name, '--colour-%s' % name,
dest="colour_%s" % name, default=default,
Expand Down Expand Up @@ -947,7 +953,8 @@ def main(argv=sys.argv):
parser = LogParser(infile, dircproxy=options.dircproxy)
formatter = style(outfile, outfilename=outfilename, colours=colours)
convert_irc_log(parser, formatter, title or filename,
prev, index, next, searchbox=options.searchbox)
prev, index, next, searchbox=options.searchbox,
hide_events=options.hide_events)
css_file = os.path.join(os.path.dirname(outfilename), 'irclog.css')
if not os.path.exists(css_file) and os.path.exists(CSS_FILE):
shutil.copy(CSS_FILE, css_file)
Expand All @@ -957,11 +964,13 @@ def main(argv=sys.argv):


def convert_irc_log(parser, formatter, title, prev, index, next,
searchbox=False):
searchbox=False, hide_events=[]):
"""Convert IRC log to HTML or some other format."""
nick_colour = NickColourizer()
formatter.head(title, prev, index, next, searchbox=searchbox)
for time, what, info in parser:
if what.value in hide_events:
continue
if what == LogParser.COMMENT:
nick, text = info
htmlcolour = nick_colour[nick]
Expand Down
Loading