def test_no_skipper(self): segment = Segment("name", "filename") segment.text = [ ''' JUST NOTHING HERE \n''', 'this is the question\n', "END SEGMENT\n" ] handler = LineSkipper() handler.handle(3, segment) self.assertEqual( ''' JUST NOTHING HERE \n''' 'this is the question\n' """END SEGMENT\n""", "".join(segment.text))
def test_skip_after(self): segment = Segment("name", "filename") segment.text = [ ''' SKIPPER \n''', 'this stays\n', 'this stays\n', ' SNIPPET SKIP AFTER "this stays"\n', 'this goes away\n', 'this goes away\n', 'this goes away\n', 'this stays\n', 'this stays\n', 'this stays\n', 'this stays\n', "END SEGMENT\n" ] handler = LineSkipper() handler.handle(3, segment) self.assertEqual( ''' SKIPPER \n''' 'this stays\n' 'this stays\n' 'this stays\n' 'this stays\n' 'this stays\n' "END SEGMENT\n", "".join(segment.text))
#! /usr/bin/python from pyama.configuration import Configuration from pyama.processor import Processor from pyama.snippet import MdSnippetWriter, SnippetReader from pyama.regexhandler import RegexHandler from pyama.linenumberer import LineNumberer from pyama.lineskipperhandler import LineSkipper MD = Configuration().file(r".*\.md$").exclude("target").handler( MdSnippetWriter(), SnippetReader(), RegexHandler(runpass=[4]), LineNumberer(runpass=[5]), LineSkipper(runpass=[3])) JAM = Configuration().file(r".*\.jam$").exclude("target").handler( SnippetReader()) POM = Configuration().file(r".*\.xml$").exclude("target").handler( SnippetReader()) configs = [MD, JAM, POM] Processor(configs, "**/*.*").process()
from pyama.snippet import MdSnippetWriter, SnippetReader, SnippetMacro snippetWriter = MdSnippetWriter() # SNIPPET SKIP AFTER '"""\)' snippetWriter.no_warning(""" WARNING:pyama.snippet:undefined snippet whatever_my_snippet is used WARNING:pyama.snippet:snippet */whatever_my_snippet is not defined WARNING:pyama.snippet:snippet filename/snippetname is not defined WARNING:pyama.snippet:snippet filename/snippetname is not defined WARNING:pyama.snippet:snippet doc/snippet.md/xetters is not defined WARNING:pyama.snippet:snippet pyama.py/run__py is not defined WARNING:pyama.snippet:undefined snippet license_handler is used WARNING:pyama.snippet:snippet */license_handler is not defined """) MD = Configuration().file(r".*\.md$").handler(snippetWriter, SnippetReader(), LineSkipper()) SEGMENT = Configuration().file(r".*\.md$").exclude( r"regexhandler\.md").handler(RegexHandler()) PY = Configuration().file(r".*\.py$").handler(SnippetReader(), ShellSnippet()) JAVA = Configuration().file(r".*\.java$").handler(SnippetReader(), SnippetMacro()) configs = [MD, PY, JAVA, SEGMENT] Processor(configs, "**/*.*").process() # END SNIPPET """ EXECUTE FOR SNIPPET run_output python3 pyama.py -h END SNIPPET