MCPcopy Create free account
hub / github.com/chasingboy/Xtools / add_prefix_suffix

Function add_prefix_suffix

utils.py:287–313  ·  view source on GitHub ↗

: cmd: prefix, suffix, prefix-line, suffix-line

(text,chars,cmd)

Source from the content-addressed store, hash-verified

285
286
287def add_prefix_suffix(text,chars,cmd):
288 '''
289 : cmd: prefix, suffix, prefix-line, suffix-line
290
291 '''
292 lines, text = text.split('\n'), ''
293
294 def concat(lines,chars,text):
295 chars = chars.split('\n')
296 if len(chars) != len(lines):
297 sublime.message_dialog('[waring] The number of text lines is not same')
298 return None
299
300 for x,line in enumerate(lines):
301 line = (chars[x] + line) if cmd == 'prefix-line' else (line+chars[x])
302 text = text + line + '\n'
303
304 return text
305
306 if 'line' in cmd:
307 return concat(lines,chars,text)
308
309 for line in lines:
310 line = (chars+line) if cmd == 'prefix' else (line+chars)
311 text = text + line + '\n'
312
313 return text
314
315
316'''

Callers 1

runMethod · 0.85

Calls 1

concatFunction · 0.85

Tested by

no test coverage detected