Commits

Peter Hosey  committed 4ecc5e7

RetrievingURLShortener now gives subclasses the ability to customize the command-line to curl.

  • Participants
  • Parent commits 3828838

Comments (0)

Files changed (1)

File Shorten-URLs.py

 	canonical_URL_suffix = 'Subclass must provide a string to append to canonical URLs that don\'t already end with it. Defaults to the empty string.'
 	canonical_URL_suffix=''
 	short_URL_exp = 'Subclass must provide regular expression object.'
+	curl_arguments = []
 
 	def shorten_URL_from_match(self, match):
 		canonical_URL = 'http://www.' + match.group(1)
 			short_URL = self.known_URLs[canonical_URL]
 		except KeyError:
 			import subprocess
-			HTML_source = subprocess.Popen(['curl', '--location', '-q', canonical_URL], stdout=subprocess.PIPE).stdout.read()
+			curl_args = ['curl'] + self.curl_arguments + ['--location', '-q', canonical_URL]
+			HTML_source = subprocess.Popen(curl_args, stdout=subprocess.PIPE).stdout.read()
 			import os
 			os.wait()
 			try: