]> git.phdru.name Git - bookmarks_db.git/commitdiff
Pass charset from the command line.
authorOleg Broytman <phd@phdru.name>
Fri, 7 Mar 2008 19:42:54 +0000 (19:42 +0000)
committerOleg Broytman <phd@phdru.name>
Fri, 7 Mar 2008 19:42:54 +0000 (19:42 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@204 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Robots/parse_html.py

index 80d4a9243bbbec31b96d98a4881182afefd05361..678f3e2dae49d9961c07e040aeca2ec7e8e832aa 100755 (executable)
@@ -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