summaryrefslogtreecommitdiff
path: root/python/skytools/scripting.py
diff options
context:
space:
mode:
authorMarko Kreen2011-11-04 12:00:15 +0000
committerMarko Kreen2011-11-04 12:00:15 +0000
commit073b183cafb5f3d40ff495b4291aa0a616646712 (patch)
treed4e8c4c7aec5c96845f8b6cf5323230fa13b3f25 /python/skytools/scripting.py
parentb313b88013f8427f2dacb160e5bc84895793e4cb (diff)
skytools.dedent: new function for removing indent
extract code from .print_ini and make usable elsewhere too.
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r--python/skytools/scripting.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py
index d671954d..6d19d223 100644
--- a/python/skytools/scripting.py
+++ b/python/skytools/scripting.py
@@ -188,7 +188,6 @@ def _init_log(job_name, service_name, cf, log_level, is_daemon):
return log
-
class BaseScript(object):
"""Base class for service scripts.
@@ -323,24 +322,12 @@ class BaseScript(object):
def _print_ini_frag(self, doc):
# use last '::' block as config template
- pos = doc and doc.rfind('::') or -1
+ pos = doc and doc.rfind('::\n') or -1
if pos < 0:
return
doc = doc[pos+2 : ].rstrip()
- # and remove same prefix from all the following lines
- pfx = None
- for ln in doc.splitlines():
- if not pfx:
- if not ln.strip():
- continue
- wslen = len(ln) - len(ln.lstrip())
- pfx = ln[ : wslen]
- if pfx:
- if ln.startswith(pfx):
- print(ln[ len(pfx) : ])
- else:
- print(ln)
+ print(skytools.dedent(doc))
print('')
def load_config(self):