Commits

Nikolaj Sjujskij committed a73f22f

Add --raw/-r/rc-file option to display 'raw' link.

Comments (0)

Files changed (1)

scripts/lodgeit.py

 SCRIPT_NAME = os.path.basename(sys.argv[0])
 VERSION = '0.3'
 SETTING_KEYS = ['author', 'title', 'language', 'private', 'clipboard',
-                'open_browser']
+                'open_browser', 'raw']
 
 # global server proxy
 _xmlrpc_service = None
         'language':     None,
         'clipboard':    True,
         'open_browser': False,
+        'raw':          False,
         'encoding':     'iso-8859-15',
         'server_name':  'http://paste.pocoo.org',
     }
                 if len(p) == 2:
                     key = p[0].strip().lower()
                     if key in settings:
-                        if key in ('clipboard', 'open_browser'):
+                        if key in ('clipboard', 'open_browser', 'raw'):
                             settings[key] = p[1].strip().lower() in \
                                             ('true', '1', 'on', 'yes')
                         else:
                       help='Open the paste in a web browser')
     parser.add_option('-p', '--private', action='store_true', default=False,
                       help='Paste as private')
+    parser.add_option('-r', '--raw', action='store_true', default=settings['raw'],
+                      help='Print "raw" link (just text, no HTML)')
     parser.add_option('--no-clipboard', dest='clipboard',
                       action='store_false',
                       default=settings['clipboard'],
     # create paste
     code = make_utf8(data, opts.encoding)
     pid = create_paste(code, language, filename, mimetype, opts.private)
-    url = '%sshow/%s/' % (_server_name, pid)
+    urltype = 'raw' if opts.raw else 'show'
+    url = '%s%s/%s/' % (_server_name, urltype, pid)
     print url
     if opts.open_browser:
         open_webbrowser(url)