Skip to content

Commit

Permalink
py3k print: WIP... overzealous fixing, breaks py2k
Browse files Browse the repository at this point in the history
  • Loading branch information
bfroehle committed Sep 27, 2012
1 parent 1981689 commit 59e98c2
Show file tree
Hide file tree
Showing 85 changed files with 446 additions and 446 deletions.
42 changes: 21 additions & 21 deletions IPython/config/application.py
Expand Up @@ -239,7 +239,7 @@ def print_alias_help(self):
help[0] = help[0].replace('--%s='%alias, '-%s '%alias)
lines.extend(help)
# lines.append('')
print os.linesep.join(lines)
print(os.linesep.join(lines))

def print_flag_help(self):
"""Print the flag part of the help."""
Expand All @@ -252,7 +252,7 @@ def print_flag_help(self):
lines.append(prefix+m)
lines.append(indent(dedent(help.strip())))
# lines.append('')
print os.linesep.join(lines)
print(os.linesep.join(lines))

def print_options(self):
if not self.flags and not self.aliases:
Expand All @@ -263,10 +263,10 @@ def print_options(self):
for p in wrap_paragraphs(self.option_description):
lines.append(p)
lines.append('')
print os.linesep.join(lines)
print(os.linesep.join(lines))
self.print_flag_help()
self.print_alias_help()
print
print()

def print_subcommands(self):
"""Print the subcommand part of the help."""
Expand All @@ -284,7 +284,7 @@ def print_subcommands(self):
if help:
lines.append(indent(dedent(help.strip())))
lines.append('')
print os.linesep.join(lines)
print(os.linesep.join(lines))

def print_help(self, classes=False):
"""Print the help for each Configurable class in self.classes.
Expand All @@ -296,25 +296,25 @@ def print_help(self, classes=False):

if classes:
if self.classes:
print "Class parameters"
print "----------------"
print
print("Class parameters")
print("----------------")
print()
for p in wrap_paragraphs(self.keyvalue_description):
print p
print
print(p)
print()

for cls in self.classes:
cls.class_print_help()
print
print()
else:
print "To see all available configurables, use `--help-all`"
print
print("To see all available configurables, use `--help-all`")
print()

def print_description(self):
"""Print the application description."""
for p in wrap_paragraphs(self.description):
print p
print
print(p)
print()

def print_examples(self):
"""Print usage and examples.
Expand All @@ -323,15 +323,15 @@ def print_examples(self):
and should contain examples of the application's usage.
"""
if self.examples:
print "Examples"
print "--------"
print
print indent(dedent(self.examples.strip()))
print
print("Examples")
print("--------")
print()
print(indent(dedent(self.examples.strip())))
print()

def print_version(self):
"""Print the version string."""
print self.version
print(self.version)

def update_config(self, config):
"""Fire the traits events when the config is updated."""
Expand Down
2 changes: 1 addition & 1 deletion IPython/config/configurable.py
Expand Up @@ -200,7 +200,7 @@ def class_get_trait_help(cls, trait, inst=None):
@classmethod
def class_print_help(cls, inst=None):
"""Get the help string for a single trait and print it."""
print cls.class_get_help(inst)
print(cls.class_get_help(inst))

@classmethod
def class_config_section(cls):
Expand Down
24 changes: 12 additions & 12 deletions IPython/core/logger.py
Expand Up @@ -137,33 +137,33 @@ def switch_log(self,val):
label = {0:'OFF',1:'ON',False:'OFF',True:'ON'}

if self.logfile is None:
print """
print("""
Logging hasn't been started yet (use logstart for that).
%logon/%logoff are for temporarily starting and stopping logging for a logfile
which already exists. But you must first start the logging process with
%logstart (optionally giving a logfile name)."""
%logstart (optionally giving a logfile name).""")

else:
if self.log_active == val:
print 'Logging is already',label[val]
print('Logging is already',label[val])
else:
print 'Switching logging',label[val]
print('Switching logging',label[val])
self.log_active = not self.log_active
self.log_active_out = self.log_active

def logstate(self):
"""Print a status message about the logger."""
if self.logfile is None:
print 'Logging has not been activated.'
print('Logging has not been activated.')
else:
state = self.log_active and 'active' or 'temporarily suspended'
print 'Filename :',self.logfname
print 'Mode :',self.logmode
print 'Output logging :',self.log_output
print 'Raw input log :',self.log_raw_input
print 'Timestamping :',self.timestamp
print 'State :',state
print('Filename :',self.logfname)
print('Mode :',self.logmode)
print('Output logging :',self.log_output)
print('Raw input log :',self.log_raw_input)
print('Timestamping :',self.timestamp)
print('State :',state)

def log(self, line_mod, line_ori):
"""Write the sources to a log.
Expand Down Expand Up @@ -213,7 +213,7 @@ def logstop(self):
self.logfile.close()
self.logfile = None
else:
print "Logging hadn't been started."
print("Logging hadn't been started.")
self.log_active = False

# For backwards compatibility, in case anyone was using this.
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magic.py
Expand Up @@ -540,8 +540,8 @@ def __init__(self, shell):

def arg_err(self,func):
"""Print docstring if incorrect arguments were passed"""
print 'Error in arguments:'
print oinspect.getdoc(func)
print('Error in arguments:')
print(oinspect.getdoc(func))

def format_latex(self, strng):
"""Format a string for latex inclusion."""
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magics/auto.py
Expand Up @@ -57,7 +57,7 @@ def automagic(self, parameter_s=''):
else:
val = not mman.auto_magic
mman.auto_magic = val
print '\n' + self.shell.magics_manager.auto_status()
print('\n' + self.shell.magics_manager.auto_status())

@skip_doctest
@line_magic
Expand Down Expand Up @@ -125,4 +125,4 @@ def autocall(self, parameter_s=''):
except AttributeError:
self.shell.autocall = self._magic_state.autocall_save = 1

print "Automatic calling is:",['OFF','Smart','Full'][self.shell.autocall]
print("Automatic calling is:",['OFF','Smart','Full'][self.shell.autocall])
22 changes: 11 additions & 11 deletions IPython/core/magics/code.py
Expand Up @@ -88,15 +88,15 @@ def save(self, parameter_s=''):
try:
overwrite = self.shell.ask_yes_no('File `%s` exists. Overwrite (y/[N])? ' % fname, default='n')
except StdinNotImplementedError:
print "File `%s` exists. Use `%%save -f %s` to force overwrite" % (fname, parameter_s)
print("File `%s` exists. Use `%%save -f %s` to force overwrite" % (fname, parameter_s))
return
if not overwrite :
print 'Operation cancelled.'
print('Operation cancelled.')
return
try:
cmds = self.shell.find_user_code(codefrom,raw)
except (TypeError, ValueError) as e:
print e.args[0]
print(e.args[0])
return
out = py3compat.cast_unicode(cmds)
with io.open(fname, mode, encoding="utf-8") as f:
Expand All @@ -106,8 +106,8 @@ def save(self, parameter_s=''):
# make sure we end on a newline
if not out.endswith(u'\n'):
f.write(u'\n')
print 'The following commands were written to file `%s`:' % fname
print cmds
print('The following commands were written to file `%s`:' % fname)
print(cmds)

@line_magic
def pastebin(self, parameter_s=''):
Expand All @@ -129,7 +129,7 @@ def pastebin(self, parameter_s=''):
try:
code = self.shell.find_user_code(args)
except (ValueError, TypeError) as e:
print e.args[0]
print(e.args[0])
return

post_data = json.dumps({
Expand Down Expand Up @@ -198,7 +198,7 @@ def load(self, arg_s):
ans = True

if ans is False :
print 'Operation cancelled.'
print('Operation cancelled.')
return

self.shell.set_next_input(contents)
Expand Down Expand Up @@ -323,7 +323,7 @@ class DataIsObject(Exception): pass

if use_temp:
filename = shell.mktempfile(data)
print 'IPython will make a temporary file named:',filename
print('IPython will make a temporary file named:',filename)

return filename, lineno, use_temp

Expand Down Expand Up @@ -493,7 +493,7 @@ def edit(self, parameter_s='',last_call=['','']):
return

# do actual editing here
print 'Editing...',
print('Editing...', end=' ')
sys.stdout.flush()
try:
# Quote filenames that may have spaces in them
Expand All @@ -510,9 +510,9 @@ def edit(self, parameter_s='',last_call=['','']):
self.shell.user_ns['pasted_block'] = file_read(filename)

if 'x' in opts: # -x prevents actual execution
print
print()
else:
print 'done. Executing edited code...'
print('done. Executing edited code...')
if 'r' in opts: # Untranslated IPython code
self.shell.run_cell(file_read(filename),
store_history=False)
Expand Down
6 changes: 3 additions & 3 deletions IPython/core/magics/config.py
Expand Up @@ -115,9 +115,9 @@ def config(self, s):
line = s.strip()
if not line:
# print available configurable names
print "Available objects for config:"
print("Available objects for config:")
for name in classnames:
print " ", name
print(" ", name)
return
elif line in classnames:
# `%config TerminalInteractiveShell` will print trait info for
Expand All @@ -127,7 +127,7 @@ def config(self, s):
help = cls.class_get_help(c)
# strip leading '--' from cl-args:
help = re.sub(re.compile(r'^--', re.MULTILINE), '', help)
print help
print(help)
return
elif '=' not in line:
raise UsageError("Invalid config statement: %r, "
Expand Down
8 changes: 4 additions & 4 deletions IPython/core/magics/deprecated.py
Expand Up @@ -26,20 +26,20 @@ class DeprecatedMagics(Magics):
@line_magic
def install_profiles(self, parameter_s=''):
"""%install_profiles has been deprecated."""
print '\n'.join([
print('\n'.join([
"%install_profiles has been deprecated.",
"Use `ipython profile list` to view available profiles.",
"Requesting a profile with `ipython profile create <name>`",
"or `ipython --profile=<name>` will start with the bundled",
"profile of that name if it exists."
])
]))

@line_magic
def install_default_config(self, parameter_s=''):
"""%install_default_config has been deprecated."""
print '\n'.join([
print('\n'.join([
"%install_default_config has been deprecated.",
"Use `ipython profile create <name>` to initialize a profile",
"with the default config files.",
"Add `--reset` to overwrite already existing config files with defaults."
])
]))

0 comments on commit 59e98c2

Please sign in to comment.