diff --git a/joy/gui/init_joy_home.py b/joy/gui/init_joy_home.py index 691cba3..4a40072 100644 --- a/joy/gui/init_joy_home.py +++ b/joy/gui/init_joy_home.py @@ -9,6 +9,7 @@ file, so you can just do, e.g.: init_joy_home.initialize(JOY_HOME) ''' +from __future__ import print_function import base64, os, StringIO, zipfile @@ -100,4 +101,4 @@ AAAAAAAAAAAAtIH2BgAAZGVmaW5pdGlvbnMudHh0UEsFBgAAAAAFAAUAHgEAAF0OAAAAAA=='''))) if __name__ == '__main__': - print create_data() + print(create_data()) diff --git a/joy/gui/main.py b/joy/gui/main.py index eb84be4..61aa77e 100755 --- a/joy/gui/main.py +++ b/joy/gui/main.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function ('''\ Joypy - Copyright © 2018 Simon Forman ''' @@ -61,12 +62,12 @@ def commands(): ] for key, command in GLOBAL_COMMANDS.iteritems(): commands.append('%s - %s' % (key.lstrip('<').rstrip('>'), command)) - print '\n'.join([''] + sorted(commands)) + print('\n'.join([''] + sorted(commands))) return args def mouse_bindings(*args): - print dedent(''' + print(dedent(''' Mouse button chords (to cancel a chord, click the third mouse button.) Left - Point, sweep selection @@ -80,13 +81,13 @@ def commands(): Right - Execute command word under mouse cursor Right-Left - Print docs of command word under mouse cursor Right-Middle - Lookup word (kinda useless now) - ''') + ''')) return args def reset_log(*args): log.delete('0.0', tk.END) - print __doc__ + print(__doc__) return args diff --git a/joy/gui/textwidget.py b/joy/gui/textwidget.py index 08c1734..1dc4f43 100644 --- a/joy/gui/textwidget.py +++ b/joy/gui/textwidget.py @@ -120,7 +120,7 @@ class SavingMixin: if not self.filename: return with open(self.filename, 'w') as f: - os.chmod(self.filename, 0600) + os.chmod(self.filename, 0o600) f.write(text.encode('UTF_8')) f.flush() os.fsync(f.fileno()) diff --git a/joy/gui/utils.py b/joy/gui/utils.py index e187d12..ef0a2d0 100644 --- a/joy/gui/utils.py +++ b/joy/gui/utils.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse, os, sys from os import listdir, mkdir from os.path import abspath, exists, expanduser, isfile, join @@ -25,10 +26,10 @@ def home_dir(path): if not exists(fullpath): if path == DEFAULT_JOY_HOME: - print 'Creating JOY_HOME', repr(fullpath) - mkdir(fullpath, 0700) + print('Creating JOY_HOME', repr(fullpath)) + mkdir(fullpath, 0o700) else: - print >> sys.stderr, repr(fullpath), "doesn't exist." + print(repr(fullpath), "doesn't exist.", file=sys.stderr) raise ValueError(path) return fullpath @@ -42,16 +43,16 @@ def init_home(fullpath): try: repo = Repo(fullpath) except NotGitRepository: - print >> sys.stderr, repr(fullpath), "no repository" + print(repr(fullpath), "no repository", file=sys.stderr) if listdir(fullpath): - print >> sys.stderr, repr(fullpath), "has contents\nQUIT." + print(repr(fullpath), "has contents\nQUIT.", file=sys.stderr) sys.exit(2) - print 'Initializing repository in', fullpath + print('Initializing repository in', fullpath) repo = init_repo(fullpath) - print 'Using repository in', fullpath + print('Using repository in', fullpath) return repo diff --git a/joy/gui/world.py b/joy/gui/world.py index 14c8dac..a06d9a8 100644 --- a/joy/gui/world.py +++ b/joy/gui/world.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with joy.py. If not see . # +from __future__ import print_function from logging import getLogger _log = getLogger(__name__) @@ -57,14 +58,14 @@ class World(object): def do_opendoc(self, name): if is_numerical(name): - print 'The number', name + print('The number', name) else: try: word = self.dictionary[name] except KeyError: - print repr(name), '???' + print(repr(name), '???') else: - print getdoc(word) + print(getdoc(word)) self.print_stack() def pop(self): @@ -99,7 +100,7 @@ class World(object): self.check_cache.clear() def has(self, name): - return self.dictionary.has_key(name) + return name in self.dictionary def save(self): pass @@ -125,15 +126,15 @@ class StackDisplayWorld(World): command = command.strip() if self.has(command) and self.check(command) == False: # not in {True, None}: return - print '\njoy?', command + print('\njoy?', command) super(StackDisplayWorld, self).interpret(command) def print_stack(self): - print '\n%s <-' % stack_to_string(self.stack) + print('\n%s <-' % stack_to_string(self.stack)) def save(self): with open(self.filename, 'wb') as f: - os.chmod(self.filename, 0600) + os.chmod(self.filename, 0o600) pickle.dump(self.stack, f) f.flush() os.fsync(f.fileno())