Skip to content

Commit 1c34c06

Browse files
committed
Python 3 preparation: replace raw_input uses.
The existing my_input in roundup/admin.py is moved to a new roundup/anypy/my_input.py, which is then used in more places. Manual patch.
1 parent 203492e commit 1c34c06

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

roundup/admin.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@
3131
from roundup.configuration import CoreConfig, NoConfigError
3232
from roundup.i18n import _
3333
from roundup.exceptions import UsageError
34-
35-
# Polyglot code
36-
try:
37-
my_input = raw_input
38-
except NameError:
39-
my_input = input
34+
from roundup.anypy.my_input import my_input
4035

4136
class CommandDict(UserDict.UserDict):
4237
"""Simple dictionary that lets us do lookups using partial keys.

roundup/anypy/my_input.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
try:
2+
# Python 2.
3+
my_input = raw_input
4+
except NameError:
5+
# Python 3+.
6+
my_input = input

roundup/mailgw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class node. Any parts of other types are each stored in separate files
101101
import email.utils
102102

103103
from .anypy.email_ import decode_header
104+
from roundup.anypy.my_input import my_input
104105

105106
from roundup import configuration, hyperdb, date, password, exceptions
106107
from roundup.mailer import Mailer, MessageSendError
@@ -1372,7 +1373,7 @@ def do_imap(self, server, user='', password='', mailbox='', ssl=0,
13721373
import getpass, imaplib, socket
13731374
try:
13741375
if not user:
1375-
user = raw_input('User: ')
1376+
user = my_input('User: ')
13761377
if not password:
13771378
password = getpass.getpass()
13781379
except (KeyboardInterrupt, EOFError):
@@ -1461,7 +1462,7 @@ def _do_pop(self, server, user, password, apop, ssl):
14611462
poplib._MAXLINE = 100*1024
14621463
try:
14631464
if not user:
1464-
user = raw_input('User: ')
1465+
user = my_input('User: ')
14651466
if not password:
14661467
password = getpass.getpass()
14671468
except (KeyboardInterrupt, EOFError):

roundup/scripts/roundup_demo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from roundup import admin, configuration, demo, instance
2626
from roundup.i18n import _
27+
from roundup.anypy.my_input import my_input
2728

2829
def run():
2930
home = DEFAULT_HOME
@@ -43,12 +44,12 @@ def run():
4344
# FIXME: i'd like to have an option to abort the tracker creation
4445
# say, by entering a single dot. but i cannot think of
4546
# appropriate prompt for that.
46-
home = raw_input(
47+
home = my_input(
4748
_('Enter directory path to create demo tracker [%s]: ') % home)
4849
if not home:
4950
home = DEFAULT_HOME
5051
templates = admin.AdminTool().listTemplates().keys()
51-
template = raw_input(
52+
template = my_input(
5253
_('Enter tracker template to use (one of (%s)) [%s]: ') %
5354
(','.join(templates),template))
5455
if not template:

scripts/imapServer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import re
4040
import time
4141

42+
from roundup.anypy.my_input import my_input
43+
4244
logging.basicConfig()
4345
log = logging.getLogger('roundup.IMAPServer')
4446

@@ -59,20 +61,20 @@ def __init__(self, dbhome='', username=None, password=None, mailbox=None
5961

6062
try:
6163
if not self.dbhome:
62-
self.dbhome = raw_input('Tracker home: ')
64+
self.dbhome = my_input('Tracker home: ')
6365
if not os.path.exists(self.dbhome):
6466
raise ValueError('Invalid home address: ' \
6567
'directory "%s" does not exist.' % self.dbhome)
6668

6769
if not self.server:
68-
self.server = raw_input('Server: ')
70+
self.server = my_input('Server: ')
6971
if not self.server:
7072
raise ValueError('No Servername supplied')
71-
protocol = raw_input('protocol [imaps]? ')
73+
protocol = my_input('protocol [imaps]? ')
7274
self.protocol = protocol
7375

7476
if not self.username:
75-
self.username = raw_input('Username: ')
77+
self.username = my_input('Username: ')
7678
if not self.username:
7779
raise ValueError('Invalid Username')
7880

@@ -83,7 +85,7 @@ def __init__(self, dbhome='', username=None, password=None, mailbox=None
8385
# by a later entry
8486

8587
#if self.mailbox is None:
86-
# self.mailbox = raw_input('Mailbox [INBOX]: ')
88+
# self.mailbox = my_input('Mailbox [INBOX]: ')
8789
# # We allow an empty mailbox because that will
8890
# # select the INBOX, whatever it is called
8991

0 commit comments

Comments
 (0)