On Feb 12, 2:24 pm, "Edward K. Ream" <[email protected]> wrote:
> The next step will be to discover what kind of data
> leoFileCommands.getLeoFile presently sets in the commander.
A little experimentation revealed that the proper question is what
kind of dummy commander is required. The following works::
# fc.ctor references c.frame.
class dummyFrame:
def __init__(self):
self.ratio = 0.0
class dummyCommander:
def __init__ (self,frame,fn):
c = self
self.changed = False
self.fn = self.mFileName = fn
self.frame = frame
self.hiddenRootNode = leoNodes.vnode(context=c)
self.p = leoNodes.position(v=None)
# Call these after setting the ivars.
self.config = leoCommands.configSettings(c)
self.cacher = leoCache.cacher(c)
def all_unique_positions(self): return []
def hash(self): return 0
def rootPosition(self): return self.p
def selectVnode(self,p): self.p = p
def setChanged(self,flag): self.changed = flag
def setCurrentPosition(self,p): self.p = p
def shortFileName(self): return self.fn
With these classes defined in the @others section, the following unit
test passes:
fn = r'C:\leo.repo\trunk\leo\doc\LeoDocs.leo'
@others
frame = dummyFrame()
c = dummyCommander(frame,fn)
theFile = open(fn,'rb')
fc = leoFileCommands.fileCommands(c)
ok,ratio =
fc.getLeoFile(theFile,fn,readAtFileNodesFlag=False,silent=False)
print(ok,ratio)
This shows that I could pass a *real* (but only partly inited)
Commander to the ctor for the fileCommands class. I could then use
the "half-inited" fileCommands class to read the .leo file.
This is simply a proof of concept. Instead of relying on a commander
at all, I might rather change fc.getLeoFile so that it simply
remembers the desired results. But surely, some way can be found to
get the job done relatively cleanly.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.