#! /usr/bin/env python
"""Test if current interpreter do not have clock() and define it as need"""
+from __future__ import print_function
import sys, time
-print "Testing...",
+print("Testing...", end=' ')
sys.stdout.flush()
time.sleep(3)
-print '\n' + " "*len("Testing...") + '\n',
+print('\n' + " "*len("Testing...") + '\n', end=' ')
need_clock = time.clock() <> 3
outfile = open("clock.py", 'w')
if need_clock:
- print "Generaing clock.py with custom clock()"
+ print("Generaing clock.py with custom clock()")
outfile.write("""\"\"\"
Define clock() for systems that do not have it
\"\"\"
return int(time() - _clock)
""")
else:
- print "Generaing clock.py with standard clock()"
+ print("Generaing clock.py with standard clock()")
outfile.write("""\"\"\"
Define clock() shim
\"\"\"
#! /usr/bin/env python
"""Define clock() for systems that do not have it"""
+from __future__ import print_function
from clock import clock
from time import sleep
-print "Testing..."
+print("Testing...")
sleep(3)
-print "Clock:", clock()
+print("Clock:", clock())
#! /usr/bin/env python
"""Get default encoding"""
-__all__ = ['default_encoding']
-
+from __future__ import print_function
import sys
try:
except ImportError:
use_locale = False
+__all__ = ['default_encoding']
+
if use_locale:
# Get the default charset.
try:
lcAll = locale.getdefaultlocale()
except locale.Error, err:
- print >>sys.stderr, "WARNING:", err
+ print("WARNING:", err, file=sys.stderr)
lcAll = []
if len(lcAll) == 2 and lcAll[0] is not None:
try:
default_encoding = locale.getpreferredencoding()
except locale.Error, err:
- print >>sys.stderr, "WARNING:", err
+ print("WARNING:", err, file=sys.stderr)
default_encoding = sys.getdefaultencoding()
else:
default_encoding = sys.getdefaultencoding()
default_encoding = default_encoding.lower()
if __name__ == "__main__":
- print default_encoding
+ print(default_encoding)
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladm
def test():
print
- print "Test 1:",
+ print("Test 1:", end=' ')
fladm.load_from_file("test.txt", fladm.check_record, None, None)
- print "Ok"
+ print("Ok")
- print "Test 2:",
+ print("Test 2:", end=' ')
fladm.load_from_file("test.txt", fladm.check_record, ["Type"], None)
- print "Ok"
+ print("Ok")
- print "Test 3:",
+ print("Test 3:", end=' ')
fladm.load_from_file("test.txt", fladm.check_record, ["Type", "Name"], None)
- print "Ok"
+ print("Ok")
- print "Test 4:",
+ print("Test 4:", end=' ')
fladm.load_from_file("test.txt", fladm.check_record, ["Type"], ["Name"])
- print "Ok"
+ print("Ok")
- print "Test 5:",
+ print("Test 5:", end=' ')
try: # Note! This must raise KeyError - "Name" key is not listed
fladm.load_from_file("test.txt", fladm.check_record, ["Type"], [""])
except KeyError:
- print "Ok"
+ print("Ok")
else:
- print "Error!"
+ print("Error!")
- print "Test 6:",
+ print("Test 6:", end=' ')
fladm.load_from_file("test.txt", fladm.check_record, None, ["Type", "Name"])
- print "Ok"
+ print("Ok")
- print "Test 7:",
+ print("Test 7:", end=' ')
try: # Note! This must raise KeyError - "Error" key is listed in must field
fladm.load_from_file("test.txt", fladm.check_record, ["Error"], ["Type"])
except KeyError:
- print "Ok"
+ print("Ok")
else:
- print "Error!"
+ print("Error!")
- print "Test 8:",
+ print("Test 8:", end=' ')
datalist = fladm.load_from_file("test.txt", fladm.check_record, None, ["Type", "Name", "Error"])
- print "Ok"
+ print("Ok")
- print "\nLast but not test: just printing loaded list"
- print datalist
+ print("\nLast but not test: just printing loaded list")
+ print(datalist)
print
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import flad
def test():
- print "Test 1:",
+ print("Test 1:", end=' ')
datalist = flad.load_from_file("test.txt")
datalist.store_to_file("test2.o1")
- print "Ok"
+ print("Ok")
- print "Test 2:",
+ print("Test 2:", end=' ')
datalist = flad.load_from_file("comment.txt")
datalist.store_to_file("test2.o2")
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladm
def test():
- print "Test:",
+ print("Test:", end=' ')
datalist = fladm.load_file("test.txt", fladm.check_record, ["Type"], ["Name"])
datalist.store_to_file("test3.out")
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladc
def test():
- print "Test:",
+ print("Test:", end=' ')
conf = fladc.load_file("test.cfg")
- print "Ok"
+ print("Ok")
- print "Property 'Type' is", conf["Type"]
+ print("Property 'Type' is", conf["Type"])
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladc
def test():
- print "Test:",
+ print("Test:", end=' ')
try: # Note! This must raise fladc.error - too many records in the file
conf = fladc.load_file("test.txt")
except fladc.error:
- print "Ok"
+ print("Ok")
else:
- print "Error!"
+ print("Error!")
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladc
def test():
- print "Test:",
+ print("Test:", end=' ')
conf = fladc.load_file("test.cfg", ["Type", "Name"])
conf.store_to_file("test6.out")
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.flad import fladw
def test():
- print "Test:",
+ print("Test:", end=' ')
ini = fladw.load_file("C:\\WINDOWS\\WIN.INI")
ini.store_to_file("test7.out")
- print "Ok"
+ print("Ok")
- print "windows/BorderWidth =", ini.get_keyvalue("windows", "BorderWidth")
+ print("windows/BorderWidth =", ini.get_keyvalue("windows", "BorderWidth"))
if __name__ == "__main__":
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import MKhash
-print "Making..."
+print("Making...")
db = MKhash.open("db", 'c')
db["test"] = "Test Ok!"
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import MKhash
-print "Testing..."
+print("Testing...")
db = MKhash.open("db", 'w')
-print db["test"]
-print len(db)
-print db.keys()
-print db.has_key("test")
-print db.has_key("Test")
-print db.get("test", "Yes")
-print db.get("Test", "No")
+print(db["test"])
+print(len(db))
+print(db.keys())
+print(db.has_key("test"))
+print(db.has_key("Test"))
+print(db.get("test", "Yes"))
+print(db.get("Test", "No"))
del db["test"]
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import MKhash
-print "Testing (more)..."
+print("Testing (more)...")
db = MKhash.open("db", 'r')
-print len(db)
-print db.keys()
-print db.has_key("test")
+print(len(db))
+print(db.keys())
+print(db.has_key("test"))
db.close()
#! /usr/bin/env python
+from __future__ import print_function
import shelve
db = shelve.open("db", 'r')
-print db["test"]
+print(db["test"])
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import zshelve
db = zshelve.CompressedShelf("dbz", 'c')
db.close()
db = zshelve.CompressedShelf("dbz", 'r')
-print db["test"]
+print(db["test"])
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import zshelve
db = zshelve.CompressedKeysShelf("dbz", 'c')
db.close()
db = zshelve.CompressedKeysShelf("dbz", 'r')
-print db["test"]
+print(db["test"])
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import zshelve
db = zshelve.CompressedKeysShelf("dbz", 'n')
db.close()
db = zshelve.CompressedKeysShelf("dbz", 'r')
-print db.has_key("test")
-print db.keys()
-print db["test"]
+print(db.has_key("test"))
+print(db.keys())
+print(db["test"])
db.close()
#! /usr/bin/env python
+from __future__ import print_function
import anydbm, dbhash
anydbm._defaultmod = dbhash
db.close()
db = zshelve.CompressedKeysShelf("dbz", 'r')
-print db.has_key("test")
-print db.keys()
-print db["test"]
+print(db.has_key("test"))
+print(db.keys())
+print(db["test"])
db.close()
#! /usr/bin/env python
+from __future__ import print_function
from m_lib.hash import ZODBhash
-print "Making..."
+print("Making...")
db = ZODBhash.open("db", 'c')
db["test"] = "Test Ok!"
db.close()
-print "Testing..."
+print("Testing...")
db = ZODBhash.open("db", 'w')
-print db["test"]
-print len(db)
-print db.keys()
-print db.has_key("test")
-print db.has_key("Test")
-print db.get("test", "Yes")
-print db.get("Test", "No")
+print(db["test"])
+print(len(db))
+print(db.keys())
+print(db.has_key("test"))
+print(db.has_key("Test"))
+print(db.get("test", "Yes"))
+print(db.get("Test", "No"))
del db["test"]
db.close()
-print "Testing (more)..."
+print("Testing (more)...")
db = ZODBhash.open("db", 'r')
-print len(db)
-print db.keys()
-print db.has_key("test")
+print(len(db))
+print(db.keys())
+print(db.has_key("test"))
db.close()
# useful function(s) for manipulating paths
#
+from __future__ import print_function
_homedir = None
def test():
- print get_homedir()
+ print(get_homedir())
if __name__ == "__main__":
"""
+from __future__ import print_function
import os, string
raise mkhier_error, "`%s' is file" % path
list_dirs = string.split(path, os.sep)
- #print list_dirs
+ #print(list_dirs)
for i in range(0, len(list_dirs)):
new_path = string.join(list_dirs[0:i+1], os.sep)
if (new_path <> '') and (not os.path.exists(new_path)):
- #print "Making", new_path
+ #print("Making", new_path)
os.mkdir(new_path)
#
+from __future__ import print_function
import random, crypt
pwd_file = open("test.pwd", 'w')
pwd_file.write("%s:%s" % ("user", encrypted))
pwd_file.close()
- print "Password file written"
+ print("Password file written")
import string
pwd_file = open("test.pwd", 'r')
pwd_file.close()
if crypt.crypt(encrypted, encrypted):
- print "Password verified Ok"
+ print("Password verified Ok")
else:
- print "BAD password"
+ print("BAD password")
if __name__ == "__main__":
test()
#! /usr/bin/env python
"""User wrapper for md5 builtin object"""
-__all__ = ['md5wrapper']
-
+from __future__ import print_function
import sys
if sys.version < '2.5':
from md5 import md5
else:
from hashlib import md5
+__all__ = ['md5wrapper']
+
class md5wrapper:
def __init__(self, init=None):
if init:
infile.close()
if __name__ == "__main__":
- print "This must print exactly the string"
- print "Test: 900150983cd24fb0d6963f7d28e17f72"
- print "Test:", md5wrapper("abc")
+ print("This must print exactly the string")
+ print("Test: 900150983cd24fb0d6963f7d28e17f72")
+ print("Test:", md5wrapper("abc"))
"""
+from __future__ import print_function
try:
from mx import DateTime
except ImportError:
def test():
#UNIX-style listing, without inum and without blocks
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 README")
- print ftpparse("dr-xr-xr-x 2 root other 512 Apr 8 1994 etc")
- print ftpparse("dr-xr-xr-x 2 root 512 Apr 8 1994 etc")
- print ftpparse("lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin")
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 README"))
+ print(ftpparse("dr-xr-xr-x 2 root other 512 Apr 8 1994 etc"))
+ print(ftpparse("dr-xr-xr-x 2 root 512 Apr 8 1994 etc"))
+ print(ftpparse("lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin"))
#FTP servers for Windoze:
- print ftpparse("---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z")
- print ftpparse("d--------- 1 owner group 0 May 9 19:45 Softlib")
+ print(ftpparse("---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z"))
+ print(ftpparse("d--------- 1 owner group 0 May 9 19:45 Softlib"))
#WFTPD for DOS:
- print ftpparse("-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp")
+ print(ftpparse("-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp"))
#NetWare:
- print ftpparse("d [R----F--] supervisor 512 Jan 16 18:53 login")
- print ftpparse("- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe")
+ print(ftpparse("d [R----F--] supervisor 512 Jan 16 18:53 login"))
+ print(ftpparse("- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe"))
#NetPresenz for the Mac:
- print ftpparse("-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit")
- print ftpparse("drwxrwxr-x folder 2 May 10 1996 network")
+ print(ftpparse("-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit"))
+ print(ftpparse("drwxrwxr-x folder 2 May 10 1996 network"))
#MultiNet (some spaces removed from examples)
- print ftpparse("00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)")
- print ftpparse("CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)")
+ print(ftpparse("00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)"))
+ print(ftpparse("CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)"))
#non-MutliNet VMS:
- print ftpparse("CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)")
+ print(ftpparse("CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)"))
#DOS format
- print ftpparse("04-27-00 09:09PM <DIR> licensed")
- print ftpparse("07-18-00 10:16AM <DIR> pub")
- print ftpparse("04-14-00 03:47PM 589 readme.htm")
+ print(ftpparse("04-27-00 09:09PM <DIR> licensed"))
+ print(ftpparse("07-18-00 10:16AM <DIR> pub"))
+ print(ftpparse("04-14-00 03:47PM 589 readme.htm"))
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 READ ME")
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 DO NOT READ ME ")
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 READ ME"))
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 DO NOT READ ME "))
if __name__ == "__main__":
test()
"""Recursive FTP scanners"""
+from __future__ import print_function
import ftplib
from m_lib.net.ftp.ftpparse import ftpparse
tree = func(ftp_server, passive=passive, reconnect=reconnect)
stop_time = time()
- print stop_time - start_time
+ print(stop_time - start_time)
logfname = "%s.list" % ftp_server
log = open(logfname, 'w')
else:
ftp_server = arguments[0]
- print "Scanning", ftp_server
+ print("Scanning", ftp_server)
try:
test(ftp_server, ftpscanrecursive, passive)
except FtpScanError, msg:
- print "Rescanning due to the error:", msg
+ print("Rescanning due to the error:", msg)
try:
test(ftp_server, ftpscan1, passive)
except EOFError:
- print "Rescanning due to the error: connection reset by peer"
+ print("Rescanning due to the error: connection reset by peer")
test(ftp_server, ftpscan1, passive, True)
except EOFError:
- print "Rescanning due to the error: connection reset by peer"
+ print("Rescanning due to the error: connection reset by peer")
test(ftp_server, ftpscan1, passive, True)
"""Common WWW/CGI utilities"""
+from __future__ import print_function
import sys, os
def exception(str = ""):
if sys.exc_type == SystemExit: # pass exit() normally
return
-
- print "Content-Type: text/html"
- print # Terminate HTTP headers
+
+ # Add the second linefeed to terminate HTTP headers
+ print("Content-Type: text/html\n")
import html
- print html.exception()
+ print(html.exception())
if str:
- print str
+ print(str)
sys.exit(1)
if not err_str:
err_str = "Unknown error"
- print "Content-Type: text/html"
- print # Terminate HTTP headers
+ # Add the second linefeed to terminate HTTP headers
+ print("Content-Type: text/html\n")
- print str(err_str)
+ print(str(err_str))
sys.exit(1)
def gen_html(title, body):
- print """
+ print("""
<HTML>
<HEAD>
<TITLE>
%s
</BODY>
</HTML>
- """ % (title, body)
+ """ % (title, body))
def mkexpires(hours=1, minutes=0, seconds=0):
#
+from __future__ import print_function
from string import *
from time import *
from calendar import *
#
def test():
- print "Is 1984 leap year?", IsLeapYear(1984)
- print "Is 1990 leap year?", IsLeapYear(1990)
+ print("Is 1984 leap year?", IsLeapYear(1984))
+ print("Is 1990 leap year?", IsLeapYear(1990))
- print "Days in month 8 year 1996:", DaysInMonth(8, 1996)
+ print("Days in month 8 year 1996:", DaysInMonth(8, 1996))
- print "Is date 8/12/1996 valid?", ValidDate(8, 12, 1996)
- print "Is date 40/11/1996 valid?", ValidDate(40, 11, 1996)
- print "Is date 8/14/1996 valid?", ValidDate(8, 14, 1996)
+ print("Is date 8/12/1996 valid?", ValidDate(8, 12, 1996))
+ print("Is date 40/11/1996 valid?", ValidDate(40, 11, 1996))
+ print("Is date 8/14/1996 valid?", ValidDate(8, 14, 1996))
- print "Date->DMY for 138219:", DateToDMY(138219)
+ print("Date->DMY for 138219:", DateToDMY(138219))
diff = DateDiff(DMYtoDate(12, 10, 1996), DMYtoDate(12, 10, 1997))
- print "Date 12/10/1996 and date 12/10/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 12/10/1996 and date 12/10/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
diff = DateDiff(DMYtoDate(12, 10, 1996), DMYtoDate(12, 11, 1997))
- print "Date 12/10/1996 and date 12/11/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 12/10/1996 and date 12/11/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
diff = DateDiff(DMYtoDate(31, 1, 1996), DMYtoDate(1, 3, 1996))
- print "Date 31/01/1996 and date 01/03/1996 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 31/01/1996 and date 01/03/1996 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
- #print "November is %dth month" % MonthStringToMonth("November")
+ #print("November is %dth month" % MonthStringToMonth("November"))
- print "Today is", Today()
- print "Now is", CurrentTime()
+ print("Today is", Today())
+ print("Now is", CurrentTime())
- print "My birthday 21 Dec 1967 is (must be Thursday):", day_name[DayOfWeekDMY(21, 12, 67)]
+ print("My birthday 21 Dec 1967 is (must be Thursday):", day_name[DayOfWeekDMY(21, 12, 67)])
gmt = DateTimeToGMT(DMYtoDate(21, 12, 1967), HMStoTime(23, 45, 0))
- print "21 Dec 1967, 23:45:00 --", gmtime(gmt) # DOS version of gmtime has error processing dates before 1/1/1970 :(
+ # DOS version of gmtime has error processing dates before 1/1/1970 :(
+ print("21 Dec 1967, 23:45:00 --", gmtime(gmt))
D, T = GMTtoDateTime(gmt)
- print "(gmt) --", DateToDMY(D), TimeToHMS(T)
+ print("(gmt) --", DateToDMY(D), TimeToHMS(T))
if __name__ == "__main__":
test()
#
+from __future__ import print_function
from string import *
#
def test():
- print "bin(0x6) =", bin(0x6)
- print "bin(0xC) =", bin(0xC)
+ print("bin(0x6) =", bin(0x6))
+ print("bin(0xC) =", bin(0xC))
- print "'Test' left-padded :", LeftPad("Test", 20)
- print "'Test' right-padded:", PadCh("Test", '*', 20)
- print "'Test' centered :", CenterCh("Test", '=', 20)
+ print("'Test' left-padded :", LeftPad("Test", 20))
+ print("'Test' right-padded:", PadCh("Test", '*', 20))
+ print("'Test' centered :", CenterCh("Test", '=', 20))
- print "'Олег':", koi2win(win2koi("Олег"))
+ print("'Олег':", koi2win(win2koi("Олег")))
if __name__ == "__main__":
test()
#! /usr/bin/env python
+from __future__ import print_function
import sys
from time import sleep
from m_lib.pbar.tty_pbar import ttyProgressBar
def test():
- print "Test: ",
+ print("Test: ", end=' ')
sys.stdout.flush()
x1 = 217
sleep(0.05)
pbar.erase()
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
Test N1 to time file reading
"""
+from __future__ import print_function
import sys
from clock import clock
def test():
- print "Test: ",
+ print("Test: ", end=' ')
sys.stdout.flush()
infile = open(sys.argv[1])
lines = infile.readlines()
infile.close()
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
test()
- print "Overall time:", clock()
+ print("Overall time:", clock())
Test N2 to time file reading
"""
+from __future__ import print_function
import sys
from clock import clock
def test():
- print "Test: ",
+ print("Test: ", end=' ')
sys.stdout.flush()
infile = open(sys.argv[1])
lines.append(line)
infile.close()
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
test()
- print "Overall time:", clock()
+ print("Overall time:", clock())
Test N3 to time file reading
"""
+from __future__ import print_function
import sys, os
from clock import clock
from m_lib.pbar.tty_pbar import ttyProgressBar
def test():
- print "Test: ",
+ print("Test: ", end=' ')
sys.stdout.flush()
size = os.path.getsize(sys.argv[1])
infile.close()
pbar.erase()
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
test()
- print "Overall time:", clock()
+ print("Overall time:", clock())
Test N4: earse()/redraw()
"""
+from __future__ import print_function
import sys
from time import sleep
from m_lib.pbar.tty_pbar import ttyProgressBar
sleep(2)
del pbar
- print "Ok"
+ print("Ok")
if __name__ == "__main__":
#! /usr/bin/env python
# -*- coding: koi8-r -*-
+from __future__ import print_function
+
#
# Lat -> Rus translation
#
if __name__ == "__main__":
Test = "Ghbdtn nt,t^ ghtrhfcysq vbh!"
- print "Test:", Test
- print "Тест:", lat2koi(Test)
- print "Тест:", unicode(lat2win(Test), "cp1251").encode("koi8-r")
+ print("Test:", Test)
+ print("Тест:", lat2koi(Test))
+ print("Тест:", unicode(lat2win(Test), "cp1251").encode("koi8-r"))
#! /usr/bin/env python
# -*- coding: koi8-r -*-
+from __future__ import print_function
+
#
# Rus -> Lat transliteration (koi2lat and win2lat)
#
if __name__ == "__main__":
Test = "Щербаков Игорь Григорьевич. АБВ xyz абв ЬЬЭЮЯ ъьэюя"
- print "Test:", Test
- print "Тест:", koi2lat(Test)
- print "Тест:", win2lat(unicode(Test, "koi8-r").encode("cp1251"))
+ print("Test:", Test)
+ print("Тест:", koi2lat(Test))
+ print("Тест:", win2lat(unicode(Test, "koi8-r").encode("cp1251")))
"""tty menus"""
+from __future__ import print_function
import string
returns selected number. Returns -1, if user enter non-numeric string.
"""
for i in range(len(item_list)):
- print format % (i, item_list[i])
+ print(format % (i, item_list[i]))
print
result = raw_input(prompt)
def test():
result = hmenu("Select: d)aily, w)eekly, m)onthly, c)ancel: ", "dwmc")
- print "Answer is '%s'\n" % result
+ print("Answer is '%s'\n" % result)
os_list = ["DOS", "Windows", "UNIX"]
result = vmenu(os_list, "Select OS: ")
if 0 <= result < len(os_list):
- print "Answer is '%s'\n" % os_list[result]
+ print("Answer is '%s'\n" % os_list[result])
else:
- print "Wrong selection"
+ print("Wrong selection")
if __name__ == "__main__":
test()