desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Add a key and cert that will be used
any time a request requires authentication.'
| def add_certificate(self, key, cert, domain):
| self.certificates.add(key, cert, domain)
|
'Remove all the names and passwords
that are used for authentication'
| def clear_credentials(self):
| self.credentials.clear()
self.authorizations = []
|
'Do the actual request using the connection object
and also follow one level of redirects if necessary'
| def _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey):
| auths = [(auth.depth(request_uri), auth) for auth in self.authorizations if auth.inscope(host, request_uri)]
auth = ((auths and sorted(auths)[0][1]) or None)
if auth:
auth.request(method, request_uri, headers, body)
(response, content) = self._conn_request(conn, request_uri, method, body, header... |
'Performs a single HTTP request.
The \'uri\' is the URI of the HTTP resource and can begin
with either \'http\' or \'https\'. The value of \'uri\' must be an absolute URI.
The \'method\' is the HTTP method to perform, such as GET, POST, DELETE, etc.
There is no restriction on the methods allowed.
The \'body\' is the en... | def request(self, uri, method='GET', body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None):
| try:
if (headers is None):
headers = {}
else:
headers = self._normalize_headers(headers)
if (not headers.has_key('user-agent')):
headers['user-agent'] = ('Python-httplib2/%s' % __version__)
uri = iri2uri(uri)
(scheme, authority, request_uri... |
'__recvall(count) -> data
Receive EXACTLY the number of bytes requested from the socket.
Blocks until the required number of bytes have been received.'
| def __recvall(self, count):
| data = self.recv(count)
while (len(data) < count):
d = self.recv((count - len(data)))
if (not d):
raise GeneralProxyError((0, 'connection closed unexpectedly'))
data = (data + d)
return data
|
'setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets the proxy to be used.
proxytype - The type of the proxy to be used. Three types
are supported: PROXY_TYPE_SOCKS4 (including socks4a),
PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr - The address of the server (IP or DNS).
port - The po... | def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None):
| self.__proxy = (proxytype, addr, port, rdns, username, password)
|
'__negotiatesocks5(self,destaddr,destport)
Negotiates a connection through a SOCKS5 server.'
| def __negotiatesocks5(self, destaddr, destport):
| if ((self.__proxy[4] != None) and (self.__proxy[5] != None)):
self.sendall(struct.pack('BBBB', 5, 2, 0, 2))
else:
self.sendall(struct.pack('BBB', 5, 1, 0))
chosenauth = self.__recvall(2)
if (chosenauth[0:1] != chr(5).encode()):
self.close()
raise GeneralProxyError((1, _ge... |
'getsockname() -> address info
Returns the bound IP address and port number at the proxy.'
| def getproxysockname(self):
| return self.__proxysockname
|
'getproxypeername() -> address info
Returns the IP and port number of the proxy.'
| def getproxypeername(self):
| return _orgsocket.getpeername(self)
|
'getpeername() -> address info
Returns the IP address and port number of the destination
machine (note: getproxypeername returns the proxy)'
| def getpeername(self):
| return self.__proxypeername
|
'__negotiatesocks4(self,destaddr,destport)
Negotiates a connection through a SOCKS4 server.'
| def __negotiatesocks4(self, destaddr, destport):
| rmtrslv = False
try:
ipaddr = socket.inet_aton(destaddr)
except socket.error:
if self.__proxy[3]:
ipaddr = struct.pack('BBBB', 0, 0, 0, 1)
rmtrslv = True
else:
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
req = (struct.pack('>BBH',... |
'__negotiatehttp(self,destaddr,destport)
Negotiates a connection through an HTTP server.'
| def __negotiatehttp(self, destaddr, destport):
| if (not self.__proxy[3]):
addr = socket.gethostbyname(destaddr)
else:
addr = destaddr
self.sendall(((((((('CONNECT ' + addr) + ':') + str(destport)) + ' HTTP/1.1\r\n') + 'Host: ') + destaddr) + '\r\n\r\n').encode())
resp = self.recv(1)
while (resp.find('\r\n\r\n'.encode()) =... |
'connect(self, despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket\'s connect).
To select the proxy server use setproxy().'
| def connect(self, destpair):
| if ((not (type(destpair) in (list, tuple))) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int)):
raise GeneralProxyError((5, _generalerrors[5]))
if (self.__proxy[0] == PROXY_TYPE_SOCKS5):
if (self.__proxy[2] != None):
portnum = self.__proxy[2]
... |
'Returns the first argument used to construct this error.'
| @property
def message(self):
| return self.args[0]
|
'An object to hold a Twitter status message.
This class is normally instantiated by the twitter.Api class and
returned in a sequence.
Note: Dates are posted in the form "Sat Jan 27 04:17:38 +0000 2007"
Args:
created_at:
The time this status message was posted. [Optional]
favorited:
Whether this is a favorite of the aut... | def __init__(self, created_at=None, favorited=None, favorite_count=None, id=None, text=None, location=None, user=None, in_reply_to_screen_name=None, in_reply_to_user_id=None, in_reply_to_status_id=None, truncated=None, source=None, now=None, urls=None, user_mentions=None, hashtags=None, media=None, geo=None, place=None... | self.created_at = created_at
self.favorited = favorited
self.favorite_count = favorite_count
self.id = id
self.text = text
self.location = location
self.user = user
self.now = now
self.in_reply_to_screen_name = in_reply_to_screen_name
self.in_reply_to_user_id = in_reply_to_user_i... |
'Get the time this status message was posted.
Returns:
The time this status message was posted'
| def GetCreatedAt(self):
| return self._created_at
|
'Set the time this status message was posted.
Args:
created_at:
The time this status message was created'
| def SetCreatedAt(self, created_at):
| self._created_at = created_at
|
'Get the time this status message was posted, in seconds since the epoch.
Returns:
The time this status message was posted, in seconds since the epoch.'
| def GetCreatedAtInSeconds(self):
| return calendar.timegm(rfc822.parsedate(self.created_at))
|
'Get the favorited setting of this status message.
Returns:
True if this status message is favorited; False otherwise'
| def GetFavorited(self):
| return self._favorited
|
'Set the favorited state of this status message.
Args:
favorited:
boolean True/False favorited state of this status message'
| def SetFavorited(self, favorited):
| self._favorited = favorited
|
'Get the favorite count of this status message.
Returns:
number of times this status message has been favorited'
| def GetFavoriteCount(self):
| return self._favorite_count
|
'Set the favorited state of this status message.
Args:
favorite_count:
int number of favorites for this status message'
| def SetFavoriteCount(self, favorite_count):
| self._favorite_count = favorite_count
|
'Get the unique id of this status message.
Returns:
The unique id of this status message'
| def GetId(self):
| return self._id
|
'Set the unique id of this status message.
Args:
id:
The unique id of this status message'
| def SetId(self, id):
| self._id = id
|
'Get the text of this status message.
Returns:
The text of this status message.'
| def GetText(self):
| return self._text
|
'Set the text of this status message.
Args:
text:
The text of this status message'
| def SetText(self, text):
| self._text = text
|
'Get the geolocation associated with this status message
Returns:
The geolocation string of this status message.'
| def GetLocation(self):
| return self._location
|
'Set the geolocation associated with this status message
Args:
location:
The geolocation string of this status message'
| def SetLocation(self, location):
| self._location = location
|
'Get a human readable string representing the posting time
Returns:
A human readable string representing the posting time'
| def GetRelativeCreatedAt(self):
| fudge = 1.25
delta = (long(self.now) - long(self.created_at_in_seconds))
if (delta < (1 * fudge)):
return 'about a second ago'
elif (delta < (60 * (1 / fudge))):
return ('about %d seconds ago' % delta)
elif (delta < (60 * fudge)):
return 'about a minut... |
'Get a twitter.User representing the entity posting this status message.
Returns:
A twitter.User representing the entity posting this status message'
| def GetUser(self):
| return self._user
|
'Set a twitter.User representing the entity posting this status message.
Args:
user:
A twitter.User representing the entity posting this status message'
| def SetUser(self, user):
| self._user = user
|
'Get the wallclock time for this status message.
Used to calculate relative_created_at. Defaults to the time
the object was instantiated.
Returns:
Whatever the status instance believes the current time to be,
in seconds since the epoch.'
| def GetNow(self):
| if (self._now is None):
self._now = time.time()
return self._now
|
'Set the wallclock time for this status message.
Used to calculate relative_created_at. Defaults to the time
the object was instantiated.
Args:
now:
The wallclock time for this instance.'
| def SetNow(self, now):
| self._now = now
|
'A string representation of this twitter.Status instance.
The return value is the same as the JSON string representation.
Returns:
A string representation of this twitter.Status instance.'
| def __str__(self):
| return self.AsJsonString()
|
'A JSON string representation of this twitter.Status instance.
Returns:
A JSON string representation of this twitter.Status instance'
| def AsJsonString(self):
| return simplejson.dumps(self.AsDict(), sort_keys=True)
|
'A dict representation of this twitter.Status instance.
The return value uses the same key names as the JSON representation.
Return:
A dict representing this twitter.Status instance'
| def AsDict(self):
| data = {}
if self.created_at:
data['created_at'] = self.created_at
if self.favorited:
data['favorited'] = self.favorited
if self.favorite_count:
data['favorite_count'] = self.favorite_count
if self.id:
data['id'] = self.id
if self.text:
data['text'] = self... |
'Create a new instance based on a JSON dict.
Args:
data: A JSON dict, as converted from the JSON in the twitter API
Returns:
A twitter.Status instance'
| @staticmethod
def NewFromJsonDict(data):
| if ('user' in data):
user = User.NewFromJsonDict(data['user'])
else:
user = None
if ('retweeted_status' in data):
retweeted_status = Status.NewFromJsonDict(data['retweeted_status'])
else:
retweeted_status = None
if ('current_user_retweet' in data):
current_use... |
'Get the unique id of this user.
Returns:
The unique id of this user'
| def GetId(self):
| return self._id
|
'Set the unique id of this user.
Args:
id: The unique id of this user.'
| def SetId(self, id):
| self._id = id
|
'Get the real name of this user.
Returns:
The real name of this user'
| def GetName(self):
| return self._name
|
'Set the real name of this user.
Args:
name: The real name of this user'
| def SetName(self, name):
| self._name = name
|
'Get the short twitter name of this user.
Returns:
The short twitter name of this user'
| def GetScreenName(self):
| return self._screen_name
|
'Set the short twitter name of this user.
Args:
screen_name: the short twitter name of this user'
| def SetScreenName(self, screen_name):
| self._screen_name = screen_name
|
'Get the geographic location of this user.
Returns:
The geographic location of this user'
| def GetLocation(self):
| return self._location
|
'Set the geographic location of this user.
Args:
location: The geographic location of this user'
| def SetLocation(self, location):
| self._location = location
|
'Get the short text description of this user.
Returns:
The short text description of this user'
| def GetDescription(self):
| return self._description
|
'Set the short text description of this user.
Args:
description: The short text description of this user'
| def SetDescription(self, description):
| self._description = description
|
'Get the homepage url of this user.
Returns:
The homepage url of this user'
| def GetUrl(self):
| return self._url
|
'Set the homepage url of this user.
Args:
url: The homepage url of this user'
| def SetUrl(self, url):
| self._url = url
|
'Get the url of the thumbnail of this user.
Returns:
The url of the thumbnail of this user'
| def GetProfileImageUrl(self):
| return self._profile_image_url
|
'Set the url of the thumbnail of this user.
Args:
profile_image_url: The url of the thumbnail of this user'
| def SetProfileImageUrl(self, profile_image_url):
| self._profile_image_url = profile_image_url
|
'Boolean for whether to tile the profile background image.
Returns:
True if the background is to be tiled, False if not, None if unset.'
| def GetProfileBackgroundTile(self):
| return self._profile_background_tile
|
'Set the boolean flag for whether to tile the profile background image.
Args:
profile_background_tile: Boolean flag for whether to tile or not.'
| def SetProfileBackgroundTile(self, profile_background_tile):
| self._profile_background_tile = profile_background_tile
|
'Returns the current time zone string for the user.
Returns:
The descriptive time zone string for the user.'
| def GetTimeZone(self):
| return self._time_zone
|
'Sets the user\'s time zone string.
Args:
time_zone:
The descriptive time zone to assign for the user.'
| def SetTimeZone(self, time_zone):
| self._time_zone = time_zone
|
'Get the latest twitter.Status of this user.
Returns:
The latest twitter.Status of this user'
| def GetStatus(self):
| return self._status
|
'Set the latest twitter.Status of this user.
Args:
status:
The latest twitter.Status of this user'
| def SetStatus(self, status):
| self._status = status
|
'Get the friend count for this user.
Returns:
The number of users this user has befriended.'
| def GetFriendsCount(self):
| return self._friends_count
|
'Set the friend count for this user.
Args:
count:
The number of users this user has befriended.'
| def SetFriendsCount(self, count):
| self._friends_count = count
|
'Get the listed count for this user.
Returns:
The number of lists this user belongs to.'
| def GetListedCount(self):
| return self._listed_count
|
'Set the listed count for this user.
Args:
count:
The number of lists this user belongs to.'
| def SetListedCount(self, count):
| self._listed_count = count
|
'Get the follower count for this user.
Returns:
The number of users following this user.'
| def GetFollowersCount(self):
| return self._followers_count
|
'Set the follower count for this user.
Args:
count:
The number of users following this user.'
| def SetFollowersCount(self, count):
| self._followers_count = count
|
'Get the number of status updates for this user.
Returns:
The number of status updates for this user.'
| def GetStatusesCount(self):
| return self._statuses_count
|
'Set the status update count for this user.
Args:
count:
The number of updates for this user.'
| def SetStatusesCount(self, count):
| self._statuses_count = count
|
'Get the number of favourites for this user.
Returns:
The number of favourites for this user.'
| def GetFavouritesCount(self):
| return self._favourites_count
|
'Set the favourite count for this user.
Args:
count:
The number of favourites for this user.'
| def SetFavouritesCount(self, count):
| self._favourites_count = count
|
'Get the setting of geo_enabled for this user.
Returns:
True/False if Geo tagging is enabled'
| def GetGeoEnabled(self):
| return self._geo_enabled
|
'Set the latest twitter.geo_enabled of this user.
Args:
geo_enabled:
True/False if Geo tagging is to be enabled'
| def SetGeoEnabled(self, geo_enabled):
| self._geo_enabled = geo_enabled
|
'Get the setting of verified for this user.
Returns:
True/False if user is a verified account'
| def GetVerified(self):
| return self._verified
|
'Set twitter.verified for this user.
Args:
verified:
True/False if user is a verified account'
| def SetVerified(self, verified):
| self._verified = verified
|
'Get the setting of lang for this user.
Returns:
language code of the user'
| def GetLang(self):
| return self._lang
|
'Set twitter.lang for this user.
Args:
lang:
language code for the user'
| def SetLang(self, lang):
| self._lang = lang
|
'Get the setting of notifications for this user.
Returns:
True/False for the notifications setting of the user'
| def GetNotifications(self):
| return self._notifications
|
'Set twitter.notifications for this user.
Args:
notifications:
True/False notifications setting for the user'
| def SetNotifications(self, notifications):
| self._notifications = notifications
|
'Get the setting of contributors_enabled for this user.
Returns:
True/False contributors_enabled of the user'
| def GetContributorsEnabled(self):
| return self._contributors_enabled
|
'Set twitter.contributors_enabled for this user.
Args:
contributors_enabled:
True/False contributors_enabled setting for the user'
| def SetContributorsEnabled(self, contributors_enabled):
| self._contributors_enabled = contributors_enabled
|
'Get the setting of created_at for this user.
Returns:
created_at value of the user'
| def GetCreatedAt(self):
| return self._created_at
|
'Set twitter.created_at for this user.
Args:
created_at:
created_at value for the user'
| def SetCreatedAt(self, created_at):
| self._created_at = created_at
|
'A string representation of this twitter.User instance.
The return value is the same as the JSON string representation.
Returns:
A string representation of this twitter.User instance.'
| def __str__(self):
| return self.AsJsonString()
|
'A JSON string representation of this twitter.User instance.
Returns:
A JSON string representation of this twitter.User instance'
| def AsJsonString(self):
| return simplejson.dumps(self.AsDict(), sort_keys=True)
|
'A dict representation of this twitter.User instance.
The return value uses the same key names as the JSON representation.
Return:
A dict representing this twitter.User instance'
| def AsDict(self):
| data = {}
if self.id:
data['id'] = self.id
if self.name:
data['name'] = self.name
if self.screen_name:
data['screen_name'] = self.screen_name
if self.location:
data['location'] = self.location
if self.description:
data['description'] = self.description
... |
'Create a new instance based on a JSON dict.
Args:
data:
A JSON dict, as converted from the JSON in the twitter API
Returns:
A twitter.User instance'
| @staticmethod
def NewFromJsonDict(data):
| if ('status' in data):
status = Status.NewFromJsonDict(data['status'])
else:
status = None
return User(id=data.get('id', None), name=data.get('name', None), screen_name=data.get('screen_name', None), location=data.get('location', None), description=data.get('description', None), statuses_cou... |
'Get the unique id of this list.
Returns:
The unique id of this list'
| def GetId(self):
| return self._id
|
'Set the unique id of this list.
Args:
id:
The unique id of this list.'
| def SetId(self, id):
| self._id = id
|
'Get the real name of this list.
Returns:
The real name of this list'
| def GetName(self):
| return self._name
|
'Set the real name of this list.
Args:
name:
The real name of this list'
| def SetName(self, name):
| self._name = name
|
'Get the slug of this list.
Returns:
The slug of this list'
| def GetSlug(self):
| return self._slug
|
'Set the slug of this list.
Args:
slug:
The slug of this list.'
| def SetSlug(self, slug):
| self._slug = slug
|
'Get the description of this list.
Returns:
The description of this list'
| def GetDescription(self):
| return self._description
|
'Set the description of this list.
Args:
description:
The description of this list.'
| def SetDescription(self, description):
| self._description = description
|
'Get the full_name of this list.
Returns:
The full_name of this list'
| def GetFull_name(self):
| return self._full_name
|
'Set the full_name of this list.
Args:
full_name:
The full_name of this list.'
| def SetFull_name(self, full_name):
| self._full_name = full_name
|
'Get the mode of this list.
Returns:
The mode of this list'
| def GetMode(self):
| return self._mode
|
'Set the mode of this list.
Args:
mode:
The mode of this list.'
| def SetMode(self, mode):
| self._mode = mode
|
'Get the uri of this list.
Returns:
The uri of this list'
| def GetUri(self):
| return self._uri
|
'Set the uri of this list.
Args:
uri:
The uri of this list.'
| def SetUri(self, uri):
| self._uri = uri
|
'Get the member_count of this list.
Returns:
The member_count of this list'
| def GetMember_count(self):
| return self._member_count
|
'Set the member_count of this list.
Args:
member_count:
The member_count of this list.'
| def SetMember_count(self, member_count):
| self._member_count = member_count
|
'Get the subscriber_count of this list.
Returns:
The subscriber_count of this list'
| def GetSubscriber_count(self):
| return self._subscriber_count
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.