Skip to content

Commit

Permalink
Add a script to add Dash docset with feed URL
Browse files Browse the repository at this point in the history
  • Loading branch information
simple committed Sep 8, 2013
1 parent 88babcf commit 729bfcc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bin/dash-add-docset.py
@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import re
import sys
import urllib

regex = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)'
'+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain
r'localhost|' # localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)

if len(sys.argv) != 2 or not regex.match(sys.argv[1]):
print "%s requires a valid URL parameter." % sys.argv[0]
sys.exit(1)
else:
os.system('open dash-feed://%s' % urllib.quote(sys.argv[1], ''))
sys.exit(0)

0 comments on commit 729bfcc

Please sign in to comment.