Coverage for C:\leo.repo\leo-editor\leo\plugins\writers\otl.py: 91%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

22 statements  

1#@+leo-ver=5-thin 

2#@+node:ekr.20140726091031.18078: * @file ../plugins/writers/otl.py 

3"""The @auto write code for vimoutline (.otl) files.""" 

4from leo.core import leoGlobals as g 

5import leo.plugins.writers.basewriter as basewriter 

6#@+others 

7#@+node:ekr.20140726091031.18083: ** class OtlWriter 

8class OtlWriter(basewriter.BaseWriter): 

9 """The writer class for .otl files.""" 

10 # def __init__(self,c): 

11 # super().__init__(c) 

12 #@+others 

13 #@+node:ekr.20140726091031.18082: *3* otlw.write 

14 def write(self, root): 

15 """Write all the *descendants* of an @auto-otl node.""" 

16 self.write_root(root) 

17 for child in root.children(): 

18 n = child.level() 

19 for p in child.self_and_subtree(): 

20 if hasattr(self.at, 'force_sentinels'): 

21 self.put_node_sentinel(p, '#') 

22 indent = '\t' * (p.level() - n) 

23 self.put('%s%s' % (indent, p.h)) 

24 for s in p.b.splitlines(False): 

25 self.put('%s: %s' % (indent, s)) 

26 root.setVisited() 

27 return True 

28 #@+node:ekr.20171230163813.1: *3* otlw.write_root 

29 def write_root(self, root): 

30 """Write the root @auto-org node.""" 

31 lines = [z for z in g.splitLines(root.b) if not g.isDirective(z)] 

32 for s in lines: 

33 self.put(s) 

34 #@-others 

35#@-others 

36writer_dict = { 

37 '@auto': ['@auto-otl', '@auto-vim-outline',], 

38 'class': OtlWriter, 

39 'extensions': ['.otl',], 

40} 

41#@@language python 

42#@@tabwidth -4 

43#@-leo