desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'__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]
... |
'Properties for this rule.'
| @property
def properties(self):
| return {'mimetype': [None]}
|
'Filter holes for titles.
:param hole:
:type hole:
:param matches:
:type matches:
:return:
:rtype:'
| def hole_filter(self, hole, matches):
| return True
|
'Filter filepart for titles.
:param filepart:
:type filepart:
:param matches:
:type matches:
:return:
:rtype:'
| def filepart_filter(self, filepart, matches):
| return True
|
'process holes
:param holes:
:type holes:
:param matches:
:type matches:
:return:
:rtype:'
| def holes_process(self, holes, matches):
| cropped_holes = []
for hole in holes:
group_markers = matches.markers.named('group')
cropped_holes.extend(hole.crop(group_markers))
return cropped_holes
|
'Ignore matches when scanning for title (hole).
Full word language and countries won\'t be ignored if they are uppercase.'
| def is_ignored(self, match):
| return ((not ((len(match) > 3) and match.raw.isupper())) and (match.name in ['language', 'country', 'episode_details']))
|
'Check if this match should be accepted when ending or starting a hole.
:param match:
:type match:
:param to_keep:
:type to_keep: list[Match]
:param matches:
:type matches: Matches
:param hole: the filepart match
:type hole: Match
:param hole: the hole match
:type hole: Match
:param starting: true if match is starting ... | def should_keep(self, match, to_keep, matches, filepart, hole, starting):
| if (match.name in ['language', 'country']):
if (len(hole.value) == len(match.raw)):
return True
outside_matches = filepart.crop(hole)
other_languages = []
for outside in outside_matches:
other_languages.extend(matches.range(outside.start, outside.end, (lambda ... |
'Check if this match should be removed after beeing ignored.
:param match:
:param matches:
:param filepart:
:param hole:
:return:'
| def should_remove(self, match, matches, filepart, hole, context):
| if ((context.get('type') == 'episode') and (match.name == 'episode_details')):
return False
return True
|
'Find title in filepart (ignoring language)'
| def check_titles_in_filepart(self, filepart, matches, context):
| (start, end) = filepart.span
holes = matches.holes(start, (end + 1), formatter=formatters(cleanup, reorder_title), ignore=self.is_ignored, predicate=(lambda hole: hole.value))
holes = self.holes_process(holes, matches)
for hole in holes:
if ((not hole) or (self.hole_filter and (not self.hole_fil... |
':param rebulk: Rebulk instance to use.
:type rebulk: Rebulk
:return:
:rtype:'
| def __init__(self, rebulk):
| self.rebulk = rebulk
|
'Retrieves all matches from string as a dict
:param string: the filename or release name
:type string: str
:param options: the filename or release name
:type options: str|dict
:return:
:rtype:'
| def guessit(self, string, options=None):
| try:
options = parse_options(options)
result_decode = False
result_encode = False
fixed_options = {}
for (key, value) in options.items():
key = GuessItApi._fix_option_encoding(key)
value = GuessItApi._fix_option_encoding(value)
fixed_option... |
'Grab properties and values that can be generated.
:param options:
:type options:
:return:
:rtype:'
| def properties(self, options=None):
| unordered = introspect(self.rebulk, options).properties
ordered = OrderedDict()
for k in sorted(unordered.keys(), key=six.text_type):
ordered[k] = list(sorted(unordered[k], key=six.text_type))
if hasattr(self.rebulk, 'customize_properties'):
ordered = self.rebulk.customize_properties(ord... |
'Initialize a ChainMap by setting *maps* to the given mappings.
If no mappings are provided, a single empty dictionary is used.'
| def __init__(self, *maps):
| self.maps = (list(maps) or [{}])
|
'Create a ChainMap with a single dict created from the iterable.'
| @classmethod
def fromkeys(cls, iterable, *args):
| return cls(dict.fromkeys(iterable, *args))
|
'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]'
| def copy(self):
| return self.__class__(self.maps[0].copy(), *self.maps[1:])
|
'New ChainMap with a new dict followed by all previous maps.'
| def new_child(self):
| return self.__class__({}, *self.maps)
|
'New ChainMap from maps[1:].'
| @property
def parents(self):
| return self.__class__(*self.maps[1:])
|
'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.'
| def popitem(self):
| try:
return self.maps[0].popitem()
except KeyError:
raise KeyError(u'No keys found in the first mapping.')
|
'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].'
| def pop(self, key, *args):
| try:
return self.maps[0].pop(key, *args)
except KeyError:
raise KeyError(u'Key not found in the first mapping: {!r}'.format(key))
|
'Clear maps[0], leaving maps[1:] intact.'
| def clear(self):
| self.maps[0].clear()
|
'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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.