Coverage for C:\leo.repo\leo-editor\leo\plugins\writers\basewriter.py: 55%
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
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
1#@+leo-ver=5-thin
2#@+node:ekr.20140726091031.18143: * @file ../plugins/writers/basewriter.py
3"""A module defining the base class for all writers in leo.plugins.writers."""
5class BaseWriter:
6 """The base writer class for all writers in leo.plugins.writers."""
8 def __init__(self, c):
9 """Ctor for leo.plugins.writers.BaseWriter."""
10 self.c = c
11 self.at = c.atFileCommands
13 #@+others
14 #@+node:ekr.20150626092123.1: ** basewriter.put
15 def put(self, s):
16 """Write line s using at.os, taking special care of newlines."""
17 at = self.at
18 at.os(s[:-1] if s.endswith('\n') else s)
19 at.onl()
20 #@+node:ekr.20150626092140.1: ** basewriter.put_node_sentinel
21 def put_node_sentinel(self, p, delim, delim2=''):
22 """Put an @+node sentinel for node p."""
23 at = self.at
24 # Like at.nodeSentinelText.
25 gnx = p.v.fileIndex
26 level = p.level()
27 if level > 2:
28 s = "%s: *%s* %s" % (gnx, level, p.h)
29 else:
30 s = "%s: %s %s" % (gnx, '*' * level, p.h)
31 # Like at.putSentinel.
32 at.os('%s@+node:%s%s' % (delim, s, delim2))
33 at.onl()
34 #@+node:ekr.20161125140611.1: ** basewriter.split_lines
35 def split_lines(self, s):
36 """Exactly the same as g.splitLines(s)."""
37 return s.splitlines(True) if s else []
38 # This is a Python string function!
39 #@-others
41#@@language python
42#@@tabwidth -4
43#@-leo