"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 1997-2014 PhiloSoft Design"
+__copyright__ = "Copyright (C) 1997-2017 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['parse_html', 'parse_filename', 'universal_charset']
parser.charset = parser.charset.lower().replace("windows-", "cp")
if title and parser.charset and (
- (parser.charset <> universal_charset) or
- ((not charset) or (charset <> parser.charset))):
+ (parser.charset != universal_charset) or
+ ((not charset) or (charset != parser.charset))):
try:
if parser.meta_charset:
if log: log(" META charset : %s" % parser.charset)
- elif (not charset) or (charset <> parser.charset):
+ elif (not charset) or (charset != parser.charset):
if log: log(" guessed charset: %s" % parser.charset)
#if log: log(" current charset: %s" % universal_charset)
if log: log(" title : %s" % title)
- if parser.charset <> universal_charset:
+ if parser.charset != universal_charset:
try:
converted_title = unicode(title, parser.charset).encode(universal_charset)
except UnicodeError:
if log: log(" incorrect conversion from %s, converting from %s" % (parser.charset, DEFAULT_CHARSET))
converted_title = unicode(title, DEFAULT_CHARSET, "replace").encode(universal_charset, "replace")
parser.charset = DEFAULT_CHARSET
- if log and (converted_title <> title): log(" converted title: %s" % converted_title)
+ if log and (converted_title != title): log(" converted title: %s" % converted_title)
except LookupError:
if log: log(" unknown charset: '%s'" % parser.charset)
else:
final_title = recode_entities(converted_title, universal_charset)
parts = [s.strip() for s in final_title.replace('\r', '').split('\n')]
final_title = ' '.join([s for s in parts if s])
- if log and (final_title <> converted_title): log(" final title : %s" % final_title)
+ if log and (final_title != converted_title): log(" final title : %s" % final_title)
parser.title = final_title
icon = parser.icon
if report_stats:
print("Broytman set-title-list, Copyright (C) 2003-2017 PhiloSoft Design")
- if len(args) <> 1:
+ if len(args) != 1:
sys.stderr.write("Usage: set-title-list [-s] title_list_file\n")
sys.exit(1)
else: # We've got 3 lines - add new entry to the mapping
if titles_dict.has_key(URL):
- if title <> titles_dict[URL]:
- raise ValueError("titles are not identical for URL `%s': `%s' <> `%s'" % (URL, title, titles_dict[URL]))
+ if title != titles_dict[URL]:
+ raise ValueError("titles are not identical for URL `%s': `%s' != `%s'" % (URL, title, titles_dict[URL]))
else:
titles_dict[URL] = title
URL = object.href
if titles_dict.has_key(URL):
name = titles_dict[URL]
- if object.name <> name:
+ if object.name != name:
object.name = name
changed += 1