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