import win32clipboard as w import win32con import sys import time import re blurb = False li = False p = False source = False table = False deltags = False print 'ARG VALUE: sys.argv[1]=', sys.argv[1] if sys.argv[1] == 'm': starter, ender = "", '' elif sys.argv[1] == 'term': starter, ender = "", '' elif sys.argv[1] == 'blurb': print 'blurb mod' starter, ender = "
\n", "
\n
\n" blurb = True elif sys.argv[1] == 'h2': starter, ender = "

", "

\n" elif sys.argv[1] == 'h3': starter, ender = "

", "

\n" elif sys.argv[1] == 'pimg': starter, ender = "


\n", "

" elif sys.argv[1] == 'p': starter, ender = "

", "

\n" p = True elif sys.argv[1] == 'li': starter, ender = "
  • ", "
  • " li = True elif sys.argv[1] == 'source': starter, ender = "
    .py
      \n
    1. ", "
    2. \n
    \n" source = True elif sys.argv[1] == 'fakelink': starter, ender = "", "" elif sys.argv[1] == 'bold': starter, ender = "", "" elif sys.argv[1] == 'italic': starter, ender = "", "" elif sys.argv[1] == 'sample': starter, ender = "
    \n", "
    \n
    \n" blurb = True elif sys.argv[1] == 'sampleinput': starter, ender = "", "" elif sys.argv[1] == 'table': starter, ender = "\n\n
    ", '
    \n' table = True elif sys.argv[1] == 'menunameclass': starter, ender = "", "" deltags = True elif sys.argv[1] == 'filenameclass': starter, ender = "", "" deltags = True else: print 'Bad input' sys.exit() def getText(): w.OpenClipboard() d=w.GetClipboardData(win32con.CF_TEXT) w.CloseClipboard() return d def setText(aType,aString): w.OpenClipboard() w.EmptyClipboard() w.SetClipboardData(aType,aString) w.CloseClipboard() def remove_html_tags(data): p = re.compile(r'<.*?>') return p.sub('', data) text = getText() print 'BEFORE:' print text if blurb: text = '
    \n'.join([x.strip() for x in text.split('\n')]) if li: text = '\n
  • '.join([x.strip() for x in text.split('\n')]) if p: text = '

    \n\n

    '.join([x.strip() for x in text.split('\n')]) if source: text = '

  • \n
  • '.join([x.strip() for x in text.split('\n')]) if table: text = "\n".join([x.strip() for x in text.split('\n')]) if deltags: text = remove_html_tags(text) text = '%s%s%s' % (starter, text, ender) print 'AFTER:' print text setText(win32con.CF_TEXT, text)