On Sat, Sep 28, 2013 at 6:33 AM, Edward K. Ream <[email protected]> wrote:
>
Thanks for doing this testing. There are several problems with
c.saveAs(), and presumably c.save and c.saveTo. I'll fix them next.
Done at rev 6074. To emphasize what is said below in the checkin log,
there is a systemic problem with the leoBridge module: it uses a nullGui in
which all dialogs are do-nothings. This will affect all commands, such as
c.save, etc., that may (or may not) ask the user for input.
The workaround I used for c.save, c.saveAs and c.saveTo was to add a
"fileName" keyword arg, so that code using a commander returned by
leoBridge can just demand that a certain fileName be used. This is as far
as I am willing to go for the 4.11 release.
Here is the checkin log:
QQQ
Added fileName keyword arg and associated logic to c.save, c.saveTo and
c.saveAs.
These tweaks are only the tip of an iceberg: the nullGui doesn't have
[any] way
of returning values from its dummy dialogs.
The following test, call it leo-bridge-test.py, passes::
# Do *not* execute this from inside Leo!
if __name__ == '__main__':
import os
import sys
sys.path.insert(0,'c:/leo.repo/trunk/leo')
import leo.core.leoBridge as leoBridge
print(leoBridge)
cc = leoBridge.controller(gui='nullGui',verbose=False)
g = cc.globals()
path = 'c:/Users/edreamleo/does-not-exist.leo'
assert not os.path.exists(path),path
assert not g.os_path_exists(path),path
c = cc.openLeoFile(path)
root = c.rootPosition()
assert root
root.h = 'root'
p = root.insertAsLastChild()
p.h = 'A'
assert p and p.h
if 0:
for p in c.all_positions():
print(p.h)
path = 'c:/Test/leo-bridge-test.leo'
c.save(fileName=path)
assert os.path.exists(path),path
assert g.os_path_exists(path),path
os.remove(path)
assert not os.path.exists(path),path
assert not g.os_path_exists(path),path
c.saveAs(fileName=path)
assert os.path.exists(path),path
assert g.os_path_exists(path),path
c.saveTo(fileName=path)
assert os.path.exists(path),path
assert g.os_path_exists(path),path
QQQ
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.