Beispiel #1
0
 def run_path(self, path):
     '''Begin execution of the python file.'''
     source = g.readFileIntoUnicodeString(path)
     fn = g.shortFileName(path)
     try:
         code = compile(source, fn, 'exec')
     except Exception:
         g.es_exception()
         return g.trace('can not compile', path)
     self.reset()
     sys.settrace(self.trace_dispatch)
     try:
         self.quitting = False
         exec(code, {}, {})
     except bdb.BdbQuit:
         if not self.quitting:
             self.do_quit()
     finally:
         self.quitting = True
         sys.settrace(None)
Beispiel #2
0
 def run_path(self, path):
     '''Begin execution of the python file.'''
     source = g.readFileIntoUnicodeString(path)
     fn = g.shortFileName(path)
     try:
         code = compile(source, fn, 'exec')
     except Exception:
         g.es_exception()
         return g.trace('can not compile', path)
     self.reset()
     sys.settrace(self.trace_dispatch)
     try:
         self.quitting = False
         exec(code, {}, {})
     except bdb.BdbQuit:
         if not self.quitting:
             self.do_quit()
     finally:
         self.quitting = True
         sys.settrace(None)
Beispiel #3
0
        if self.in_ == 't':
            self.idx[self.in_attrs['tx']].b.append(content)

    #@-others


#@+node:ekr.20120519121124.9931: ** get_leo_data
def get_leo_data(source):
    """Return the root node for the specificed .leo file (path or file)"""
    parser = LeoReader()
    if g.os_path_isfile(source):
        source = g.readFileIntoEncodedString(source)
    parseString(source, parser)
    return parser.root


#@-others
#@@language python
#@@tabwidth -4
#@@pagewidth 70

if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1 and g.os_path_isfile(sys.argv[1]):
        wb = sys.argv[1]
    else:
        wb = g.os_path_expanduser(g.os_path_join('~', '.leo', 'workbook.leo'))
    leo_data = get_leo_data(g.readFileIntoUnicodeString(wb))
    print(leo_data)
#@-leo
Beispiel #4
0
        if self.in_ == 't':
            self.idx[self.in_attrs['tx']].b.append(content)

    #@-others
#@+node:ekr.20120519121124.9931: ** get_leo_data
def get_leo_data(source):
    """Return the root node for the specificed .leo file (path or file)"""
    parser = LeoReader()
    if g.os_path_isfile(source):
        source = g.readFileIntoEncodedString(source)
    parseString(source, parser)
    return parser.root

#@-others
#@@language python
#@@tabwidth -4
#@@pagewidth 70

if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1 and g.os_path_isfile(sys.argv[1]):
        wb = sys.argv[1]
    else:
        wb = g.os_path_expanduser(
            g.os_path_join('~', '.leo', 'workbook.leo')
        )
    leo_data = get_leo_data(g.readFileIntoUnicodeString(wb))
    print(leo_data)
#@-leo