-import BaseHTTPServer
from collections import namedtuple
import contextlib
import functools
import socket
-import SocketServer
import threading
from twitter.util import find_links, follow_redirects, expand_line, parse_host_list
+try:
+ import http.server as BaseHTTPServer
+ import socketserver as SocketServer
+except ImportError:
+ import BaseHTTPServer
+ import SocketServer
+
def test_find_links():
assert find_links("nix") == ("nix", [])
response = responses.pop()
assert response.path == self.path
self.send_response(response.code)
- for header, value in response.headers.iteritems():
+ for header, value in list(response.headers.items()):
self.send_header(header, value)
self.end_headers()
from __future__ import print_function
-import os, sys, time, calendar, urllib2, httplib, functools
+import os, sys, time, calendar, functools
from getopt import gnu_getopt as getopt, GetoptError
+try:
+ import urllib.request as urllib2
+ import http.client as httplib
+except ImportError:
+ import urllib2
+ import httplib
+
+
# T-Archiver (Twitter-Archiver) application registered by @stalkr_
CONSUMER_KEY='d8hIyfzs7ievqeeZLjZrqQ'
CONSUMER_SECRET='AnZmK0rnvaX7BoJ75l6XlilnbyMv7FoiDXWVmPD8'
tweets = {}
try:
tweets = load_tweets(filename)
- except Exception, e:
+ except Exception as e:
err("Error when loading saved tweets: %s - continuing without"
% str(e))
tweets = {}
try:
tweets = load_tweets(filename)
- except Exception, e:
+ except Exception as e:
err("Error when loading saved tweets: %s - continuing without"
% str(e))
from __future__ import print_function
-import os, sys, time, calendar, urllib2, httplib
+import os, sys, time, calendar
from getopt import gnu_getopt as getopt, GetoptError
+try:
+ import urllib.request as urllib2
+ import http.client as httplib
+except ImportError:
+ import urllib2
+ import httplib
+
# T-Follow (Twitter-Follow) application registered by @stalkr_
CONSUMER_KEY='USRZQfvFFjB6UvZIN2Edww'
CONSUMER_SECRET='AwGAaSzZa5r0TDL8RKCDtffnI9H9mooZUdOa95nw8'
from .auth import NoAuth
from .util import Fail, err
+
def parse_args(args, options):
"""Parse arguments from command-line to set options."""
long_opts = ['help', 'oauth', 'followers', 'following', 'api-rate']
import re
import sys
import time
-import urllib2
-import urlparse
try:
from html.entities import name2codepoint
unichr = chr
+ import urllib.request as urllib2
+ import urllib.parse as urlparse
except ImportError:
from htmlentitydefs import name2codepoint
+ import urllib2
+ import urlparse
def htmlentitydecode(s):
return re.sub(
def find_links(line):
"""Find all links in the given line. The function returns a sprintf style
format string (with %s placeholders for the links) and a list of urls."""
- l = line.replace(u"%", u"%%")
+ l = line.replace("%", "%%")
regex = "(https?://[^ )]+)"
return (
re.sub(regex, "%s", l),