#! /usr/bin/env python
# -*- coding: koi8-r -*-
-
import sys
src_encoding = sys.argv[1]
elif dst_encoding == "cp1251":
from m_lib.rus.lat2rus import lat2win as _recode
else:
- raise NotImplementedError, "destination encoding must be koi8-r or cp1251, not `%s'" % dst_encoding
+ raise NotImplementedError("destination encoding must be koi8-r or cp1251, not `%s'" % dst_encoding)
elif dst_encoding == "translit":
if src_encoding == "koi8-r":
elif src_encoding == "cp1251":
from m_lib.rus.rus2lat import win2lat as _recode
else:
- raise NotImplementedError, "source encoding must be koi8-r or cp1251, not `%s'" % src_encoding
+ raise NotImplementedError("source encoding must be koi8-r or cp1251, not `%s'" % src_encoding)
from m_lib.rus.rus2lat import koi2lat_d
koi2lat_d["ะช"] = '' # remove apostrophs -
import urllib
def _recode(s):
s = urllib.unquote(s)
- if src_encoding <> dst_encoding:
+ if src_encoding != dst_encoding:
s = recode(s, src_encoding, dst_encoding, "replace")
return s
from m_lib.opstring import recode
import urllib
def _recode(s):
- if src_encoding <> dst_encoding:
+ if src_encoding != dst_encoding:
s = recode(s, src_encoding, dst_encoding, "replace")
return urllib.quote(s, safe=";/?:@&=+$,()'") # wget treats them as safe
import os
for filename in sys.argv[3:]:
new_name = _recode(filename)
- if new_name <> filename:
+ if new_name != filename:
os.rename(filename, new_name)