From 2f06deff348d6a49ba7f8f0d941e0bd3445e6418 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 7 Mar 2008 19:42:54 +0000 Subject: [PATCH] Pass charset from the command line. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@204 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/parse_html.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Robots/parse_html.py b/Robots/parse_html.py index 80d4a92..678f3e2 100755 --- a/Robots/parse_html.py +++ b/Robots/parse_html.py @@ -119,10 +119,18 @@ def parse_html(filename, charset=None, log=None): if __name__ == '__main__': import sys - from m_lib.defenc import default_encoding - current_charset = default_encoding.replace("windows-", "cp") - parser = parse_html(sys.argv[1], universal_charset, + l = len(sys.argv) + if l == 3: + filename = sys.argv[1] + charset = sys.argv[2] + elif l == 2: + filename = sys.argv[1] + charset = universal_charset + else: + sys.exit("Usage: %s filename [charset]" % sys.argv[0]) + + parser = parse_html(filename, universal_charset, log=lambda s: sys.stdout.write(s + '\n')) print " refresh:", parser.refresh print " icon :", parser.icon -- 2.39.5