futurize stage1 vui
This commit is contained in:
parent
89b4eb5e15
commit
00db0fd0ad
|
|
@ -28,6 +28,7 @@ passing, a "world" class that holds the main context for the system, and
|
|||
a mainloop class that manages the, uh, main loop (the PyGame event queue.)
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
from sys import stderr
|
||||
from traceback import format_exc
|
||||
import pygame
|
||||
|
|
@ -172,7 +173,7 @@ class World(object):
|
|||
try:
|
||||
return stack_to_string(self.stack_holder[0])
|
||||
except:
|
||||
print >> stderr, format_exc()
|
||||
print(format_exc(), file=stderr)
|
||||
return str(self.stack_holder[0])
|
||||
|
||||
|
||||
|
|
@ -250,8 +251,8 @@ class TheLoop(object):
|
|||
except:
|
||||
traceback = format_exc()
|
||||
self.remove_task(task_event_id)
|
||||
print >> stderr, traceback
|
||||
print >> stderr, 'TASK removed due to ERROR', task
|
||||
print(traceback, file=stderr)
|
||||
print('TASK removed due to ERROR', task, file=stderr)
|
||||
open_viewer_on_string(self, traceback, self.display.broadcast)
|
||||
|
||||
def loop(self):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
import sys, traceback
|
||||
|
||||
# To enable "hot" reloading in the IDLE shell.
|
||||
|
|
@ -7,7 +8,7 @@ for name in 'core main display viewer text_viewer stack_viewer persist_task'.spl
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
import main
|
||||
from . import main
|
||||
|
||||
try:
|
||||
A = A # (screen, clock, pt), three things that we DON'T want to recreate
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ Refer to Chapter 4 of the Project Oberon book for more information.
|
|||
There is a Display object that manages a pygame surface and N vertical
|
||||
tracks each of which manages zero or more viewers.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
from copy import copy
|
||||
from sys import stderr
|
||||
from traceback import format_exc
|
||||
|
|
@ -283,14 +284,14 @@ class Display(object):
|
|||
elif event.type in MOUSE_EVENTS:
|
||||
self._mouse_event(event)
|
||||
else:
|
||||
print >> stderr, (
|
||||
print((
|
||||
'received event %s Use pygame.event.set_allowed().'
|
||||
% pygame.event.event_name(event.type)
|
||||
)
|
||||
), file=stderr)
|
||||
# Catch all exceptions and open a viewer.
|
||||
except:
|
||||
err = format_exc()
|
||||
print >> stderr, err # To be safe just print it right away.
|
||||
print(err, file=stderr) # To be safe just print it right away.
|
||||
open_viewer_on_string(self, err, self.broadcast)
|
||||
|
||||
def _keyboard_event(self, event):
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Thun. If not see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import print_function
|
||||
from StringIO import StringIO
|
||||
import base64, zlib
|
||||
|
||||
|
|
@ -183,4 +184,4 @@ lnalXc/9SsNb2vUirzS8pV0v8gJv/w/2vRht''')))
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print create()
|
||||
print(create())
|
||||
|
|
|
|||
|
|
@ -28,6 +28,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
|
||||
|
||||
|
||||
|
|
@ -272,4 +273,4 @@ c3RhY2sucGlja2xlUEsFBgAAAAAGAAYAUwEAACcwAAAAAA==''')))
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print create_data()
|
||||
print(create_data())
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ Main Module
|
|||
Pulls everything together.
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import os, sys, traceback
|
||||
import pygame
|
||||
from joy.library import initialize, DefinitionWrapper, SimpleFunctionWrapper
|
||||
|
|
@ -67,9 +68,9 @@ def init():
|
|||
* Create the PersistTask
|
||||
|
||||
'''
|
||||
print 'Initializing Pygame...'
|
||||
print('Initializing Pygame...')
|
||||
pygame.init()
|
||||
print 'Creating window...'
|
||||
print('Creating window...')
|
||||
if FULLSCREEN:
|
||||
screen = pygame.display.set_mode()
|
||||
else:
|
||||
|
|
@ -159,7 +160,7 @@ def main(screen, clock, pt):
|
|||
def evaluate(stack):
|
||||
'''Evaluate the Python code text on the top of the stack.'''
|
||||
code, stack = stack
|
||||
exec code in name_space.copy()
|
||||
exec(code, name_space.copy())
|
||||
return stack
|
||||
|
||||
name_space['D']['evaluate'] = evaluate
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ This module deals with persisting the "resources" (text files and the
|
|||
stack) to the git repo in the ``JOY_HOME`` directory.
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import os, pickle, traceback
|
||||
from collections import Counter
|
||||
from dulwich.errors import NotGitRepository
|
||||
|
|
@ -42,7 +43,7 @@ def open_repo(repo_dir=None, initialize=False):
|
|||
exception is raised, otherwise ``git init`` is effected in the dir.
|
||||
'''
|
||||
if not os.path.exists(repo_dir):
|
||||
os.makedirs(repo_dir, 0700)
|
||||
os.makedirs(repo_dir, 0o700)
|
||||
return init_repo(repo_dir)
|
||||
try:
|
||||
return Repo(repo_dir)
|
||||
|
|
@ -95,14 +96,14 @@ class Resource(object):
|
|||
|
||||
def _to_file(self, f):
|
||||
for line in self.thing:
|
||||
print >> f, line
|
||||
print(line, file=f)
|
||||
|
||||
def persist(self, repo):
|
||||
'''
|
||||
Save the lines to the file and stage the file in the repo.
|
||||
'''
|
||||
with open(self.filename, 'w') as f:
|
||||
os.chmod(self.filename, 0600)
|
||||
os.chmod(self.filename, 0o600)
|
||||
self._to_file(f)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
|
|
@ -266,7 +267,7 @@ if __name__ == '__main__':
|
|||
pt = PersistTask(JOY_HOME)
|
||||
content_id, thing = pt.open('stack.pickle')
|
||||
pt.persist(content_id)
|
||||
print pt.counter
|
||||
print(pt.counter)
|
||||
mm = core.ModifyMessage(None, None, content_id=content_id)
|
||||
pt.handle(mm)
|
||||
print pt.counter
|
||||
print(pt.counter)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ Text Viewer
|
|||
=================
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import string
|
||||
import pygame
|
||||
from joy.utils.stack import expression_to_string
|
||||
|
|
@ -415,7 +416,7 @@ class TextViewer(MenuViewer):
|
|||
self._printable_key(uch, mod, line, i)
|
||||
modified = True
|
||||
else:
|
||||
print '%r %i %s' % (uch, key, bin(mod))
|
||||
print('%r %i %s' % (uch, key, bin(mod)))
|
||||
|
||||
if modified:
|
||||
# The selection is fragile.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ Viewer
|
|||
=================
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import pygame
|
||||
from joy.vui.core import BACKGROUND, FOREGROUND
|
||||
|
||||
|
|
@ -227,7 +228,7 @@ class SomeViewer(MenuViewer):
|
|||
|
||||
def key_down(self, display, uch, key, mod):
|
||||
try:
|
||||
print chr(key),
|
||||
print(chr(key), end=' ')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue