index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
8.19k
signature
stringlengths
2
42.8k
embed_func_code
listlengths
768
768
7,221
wikitools3.wikifile
FileDimensionError
Invalid dimensions
class FileDimensionError(wiki.WikiError): """Invalid dimensions"""
null
[ -0.004814644809812307, -0.005455770529806614, -0.024536490440368652, 0.07253403216600418, -0.005972806829959154, 0.018398230895400047, -0.005877672228962183, -0.01791842095553875, -0.022087804973125458, 0.03835170716047287, 0.07928445935249329, 0.031750183552503586, 0.02281579189002514, -0...
7,222
urllib.request
HTTPPasswordMgrWithDefaultRealm
null
class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self, realm, authuri) if user is not None: return user, password ...
()
[ 0.030080294236540794, 0.005516869947314262, 0.06296046823263168, 0.0500294454395771, -0.010803486220538616, -0.038977283984422684, 0.018291324377059937, 0.003142958041280508, -0.0059267207980155945, -0.018751831725239754, 0.05279248207807541, 0.0124244699254632, -0.05533447861671448, 0.011...
7,223
urllib.request
__init__
null
def __init__(self): self.passwd = {}
(self)
[ 0.03182810917496681, 0.0005606086924672127, 0.017939478158950806, 0.03143129125237465, -0.007510606665164232, -0.047320540994405746, 0.010275932028889656, 0.03898736461997032, 0.047122132033109665, -0.0005027394508942962, -0.002120496006682515, 0.05899360403418541, -0.05466167628765106, 0....
7,224
urllib.request
add_password
null
def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence if isinstance(uri, str): uri = [uri] if realm not in self.passwd: self.passwd[realm] = {} for default_port in True, False: reduced_uri = tuple( self.reduce_uri(u, default_port)...
(self, realm, uri, user, passwd)
[ 0.012191356159746647, 0.03383323550224304, 0.02993556298315525, 0.07051409035921097, -0.001409347401931882, 0.0014171338407322764, 0.02025366947054863, 0.021392714232206345, 0.02872532606124878, -0.018918849527835846, 0.030487287789583206, 0.04730601981282234, -0.05535053461790085, 0.06503...
7,225
urllib.request
find_user_password
null
def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self, realm, authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri)
(self, realm, authuri)
[ 0.027501888573169708, 0.020166825503110886, 0.04360593482851982, 0.08552057296037674, 0.007601624820381403, -0.03167496994137764, 0.033255960792303085, -0.005129028577357531, -0.021398527547717094, -0.048532743006944656, 0.029119646176695824, 0.010552194900810719, -0.05691567063331604, 0.0...
7,226
urllib.request
is_suburi
Check if test is below base in a URI tree Both args must be URIs in reduced form.
def is_suburi(self, base, test): """Check if test is below base in a URI tree Both args must be URIs in reduced form. """ if base == test: return True if base[0] != test[0]: return False prefix = base[1] if prefix[-1:] != '/': prefix += '/' return test[1].startswi...
(self, base, test)
[ -0.053860586136579514, -0.012742585502564907, -0.0012283546384423971, 0.05811094865202904, -0.022832944989204407, 0.007280869875103235, 0.029650526121258736, 0.06324538588523865, 0.005805994383990765, -0.07861469686031342, 0.031690698117017746, 0.07650651782751083, 0.031350668519735336, 0....
7,227
urllib.request
reduce_uri
Accept authority or URI and extract only the authority and path.
def reduce_uri(self, uri, default_port=True): """Accept authority or URI and extract only the authority and path.""" # note HTTP URLs do not have a userinfo component parts = urlsplit(uri) if parts[1]: # URI scheme = parts[0] authority = parts[1] path = parts[2] or '/' ...
(self, uri, default_port=True)
[ -0.03058692254126072, 0.007946865633130074, 0.03415270894765854, 0.035066552460193634, -0.0035971440374851227, -0.055439915508031845, 0.053325530141592026, -0.010751115158200264, 0.04350617900490761, -0.028902580961585045, 0.04816499724984169, 0.044043734669685364, -0.043362829834222794, 0...
7,228
wikitools3.wiki
Namespace
Class for namespace 'constants' Names are based on canonical (non-localized) names This functions as an integer in every way, except that the OR operator ( | ) is overridden to produce a string namespace list for use in API queries wikiobj.NS_MAIN|wikiobj.NS_USER|wikiobj.NS_PROJECT returns '0|2|4' ...
class Namespace(int): """ Class for namespace 'constants' Names are based on canonical (non-localized) names This functions as an integer in every way, except that the OR operator ( | ) is overridden to produce a string namespace list for use in API queries wikiobj.NS_MAIN|wikiobj.NS_USER|wikiob...
null
[ -0.008570719510316849, -0.027119291946291924, -0.007858015596866608, -0.032199591398239136, 0.005934629589319229, -0.04382214695215225, -0.026187295094132423, -0.01066314522176981, 0.09539265930652618, -0.05690665543079376, 0.0065605295822024345, 0.04199469834566116, 0.05230149254202843, 0...
7,229
wikitools3.wiki
__or__
null
def __or__(self, other): return "|".join([str(self), str(other)])
(self, other)
[ -0.013735427521169186, -0.03408574312925339, 0.0456244982779026, 0.0274045392870903, -0.015658553689718246, -0.10742977261543274, -0.008629197254776955, 0.02864794060587883, 0.10736346244812012, -0.036605700850486755, 0.036174654960632324, 0.009076821617782116, 0.023740654811263084, 0.0315...
7,230
wikitools3.wiki
__ror__
null
def __ror__(self, other): return "|".join([str(other), str(self)])
(self, other)
[ -0.04423702135682106, -0.003036078531295061, 0.05111462250351906, 0.03358674794435501, -0.00834660790860653, -0.10416565835475922, -0.02911296673119068, 0.02859547734260559, 0.1095074936747551, -0.041599493473768234, 0.026492131873965263, 0.012494871392846107, 0.04847709462046623, 0.060095...
7,231
wikitools3.page
NoPage
Non-existent page
class NoPage(wiki.WikiError): """Non-existent page"""
null
[ -0.03826391324400902, -0.015403282828629017, 0.0019082670332863927, 0.042892612516880035, -0.027223609387874603, 0.018051927909255028, 0.03678958863019943, 0.005807303357869387, -0.016869036480784416, 0.002209346741437912, 0.06764758378267288, 0.05125855654478073, 0.04488123953342438, -0.0...
7,232
wikitools3.page
Page
A page on the wiki
class Page(object): """A page on the wiki""" def __init__( self, site, title=False, check=True, followRedir=True, section=False, sectionnumber=None, pageid=False, namespace=False, ): """ wiki - A wiki object tit...
(site, title=False, check=True, followRedir=True, section=False, sectionnumber=None, pageid=False, namespace=False)
[ -0.028118649497628212, 0.021329360082745552, -0.0653027668595314, 0.00630854582414031, 0.010694113560020924, 0.01898450404405594, -0.009011507034301758, 0.031199339777231216, -0.06683330237865448, -0.03180762752890587, 0.015403447672724724, 0.03204309567809105, 0.05541316792368889, 0.03567...
7,238
wikitools3.page
__init__
wiki - A wiki object title - The page title, as a string or unicode object check - Checks for existence, normalizes title, required for most things followRedir - follow redirects (check must be true) section - the section name sectionnumber - the section number p...
def __init__( self, site, title=False, check=True, followRedir=True, section=False, sectionnumber=None, pageid=False, namespace=False, ): """ wiki - A wiki object title - The page title, as a string or unicode object check - Checks for existence, normalizes title, req...
(self, site, title=False, check=True, followRedir=True, section=False, sectionnumber=None, pageid=False, namespace=False)
[ -0.041045304387807846, 0.03683648258447647, -0.036147426813840866, 0.002467560116201639, 0.005638142116367817, 0.011983961798250675, -0.009423286654055119, 0.039443716406822205, -0.04287036508321762, 0.0024698879569768906, 0.026053709909319878, 0.06026433780789375, 0.05475190281867981, 0.0...
7,260
wikitools3.page
ProtectError
Problem with protection request
class ProtectError(wiki.WikiError): """Problem with protection request"""
null
[ -0.02123059704899788, -0.012008178047835827, -0.003088558791205287, 0.08104655146598816, -0.00837457925081253, -0.029086092486977577, 0.0007034690352156758, 0.0025240532122552395, -0.013487571850419044, 0.025400584563612938, 0.06540477275848389, 0.04052327573299408, 0.03678585961461067, -0...
7,262
wikitools3.wikifile
UploadError
Error during uploading
class UploadError(wiki.WikiError): """Error during uploading"""
null
[ -0.0548538938164711, -0.035517286509275436, -0.028978757560253143, 0.08369316160678864, -0.032169558107852936, -0.026328474283218384, 0.004097477532923222, 0.021341755986213684, -0.005984933115541935, 0.010078052058815956, 0.07406844943761826, 0.009668303653597832, 0.03839423879981041, -0....
7,263
wikitools3.user
User
A user on the wiki
class User: """A user on the wiki""" def __init__(self, site, name, check=True): """ wiki - A wiki object name - The username, as a string check - Checks for existence, normalizes name """ self.site = site self.name = name.strip() if not isinstanc...
(site, name, check=True)
[ 0.014917195774614811, -0.017545463517308235, -0.055325545370578766, 0.0690453052520752, -0.04493424668908119, -0.06206365302205086, -0.03143773600459099, -0.02748011238873005, -0.0372016578912735, -0.04040835052728653, -0.02760188654065132, -0.01864141970872879, -0.009117755107581615, 0.05...
7,264
wikitools3.user
IPcheck
null
def IPcheck(self): try: # IPv4 check s = socket.inet_aton(self.name.replace(" ", "_")) if socket.inet_ntoa(s) == self.name: self.isIP = True self.exists = False return except: pass try: s = socket.inet_pton(socket.AF_INET6, self.name.replace("...
(self)
[ 0.03447329252958298, -0.015196281485259533, -0.022248845547437668, 0.031226450577378273, -0.062062572687864304, -0.04595256224274635, 0.021982712671160698, -0.005810603965073824, 0.041268594563007355, -0.05383014306426048, -0.0006154361180961132, 0.017050351947546005, 0.029132859781384468, ...
7,265
wikitools3.user
IPnorm
This is basically a port of MediaWiki's IP::sanitizeIP but assuming no CIDR ranges
def IPnorm(self, ip): """This is basically a port of MediaWiki's IP::sanitizeIP but assuming no CIDR ranges""" ip = ip.upper() # Expand zero abbreviations abbrevPos = ip.find("::") if abbrevPos != -1: addressEnd = len(ip) - 1 # If the '::' is at the beginning... if abbrevPos ...
(self, ip)
[ -0.023987388238310814, 0.015422963537275791, 0.04160613194108009, 0.023602470755577087, -0.06655581295490265, -0.07432416081428528, 0.03485257178544998, -0.04503540322184563, 0.049374476075172424, -0.029953615739941597, -0.021467924118041992, 0.038106877356767654, -0.0030618475284427404, 0...
7,266
wikitools3.user
__eq__
null
def __eq__(self, other): if not isinstance(other, User): return False if self.name == other.name and self.site == other.site: return True return False
(self, other)
[ 0.027470342814922333, -0.011866750195622444, 0.0033563217148184776, 0.04436815530061722, -0.028928620740771294, -0.07604928314685822, -0.011875864118337631, -0.0027889597695320845, 0.028527595102787018, 0.02759794145822525, 0.022767391055822372, -0.06303413212299347, 0.042800504714250565, ...
7,267
wikitools3.user
__hash__
null
def __hash__(self): return int(self.name) ^ hash(self.site.apibase)
(self)
[ 0.028474481776356697, -0.047142960131168365, -0.0032581379637122154, 0.05263566970825195, -0.014119299128651619, -0.0603187270462513, -0.031237686052918434, -0.053511809557676315, 0.009898673743009567, -0.014658461324870586, -0.026115648448467255, 0.0012931458186358213, 0.020656635984778404,...
7,268
wikitools3.user
__init__
wiki - A wiki object name - The username, as a string check - Checks for existence, normalizes name
def __init__(self, site, name, check=True): """ wiki - A wiki object name - The username, as a string check - Checks for existence, normalizes name """ self.site = site self.name = name.strip() if not isinstance(self.name, str): self.name = str(self.name, "utf8") self.exists ...
(self, site, name, check=True)
[ -0.008349982090294361, 0.002499223919585347, -0.05618148669600487, 0.05529366433620453, -0.03732411190867424, -0.01584765315055847, 0.01997603476047516, -0.005730902310460806, -0.026048747822642326, 0.004865274298936129, 0.010813693515956402, 0.04375195503234863, -0.00012713913747575134, 0...
7,269
wikitools3.user
__ne__
null
def __ne__(self, other): if not isinstance(other, User): return True if self.name == other.name and self.site == other.site: return False return True
(self, other)
[ 0.007172459736466408, 0.01530064083635807, 0.016502119600772858, 0.05180918797850609, -0.0756567046046257, -0.07580234110355377, -0.030018746852874756, 0.0019182689720764756, 0.05759812891483307, 0.031056387349963188, 0.026286883279681206, -0.05639665201306343, 0.01637468859553337, 0.02435...
7,270
wikitools3.user
__repr__
null
def __repr__(self): return ( "<" + self.__module__ + "." + self.__class__.__name__ + " " + repr(self.name) + " on " + repr(self.site.apibase) + ">" )
(self)
[ 0.008176417089998722, -0.04875468090176582, 0.047110460698604584, 0.010106587782502174, 0.048290010541677475, -0.07295329868793488, 0.02141059748828411, -0.03467158228158951, 0.031972918659448624, -0.04146292433142662, -0.03386734798550606, 0.019355323165655136, -0.011706127785146236, 0.05...
7,271
wikitools3.user
__str__
null
def __str__(self): return ( self.__class__.__name__ + " " + repr(self.name) + " on " + repr(self.site.domain) )
(self)
[ -0.002072103088721633, -0.005638254806399345, 0.020845536142587662, 0.015109456144273281, 0.038525111973285675, -0.055279798805713654, 0.02872486226260662, -0.07989602535963058, 0.06410180032253265, -0.03199754282832146, -0.04147763550281525, -0.016078809276223183, -0.018284309655427933, -...
7,272
wikitools3.user
block
Block the user Params are the same as the API reason - block reason expiry - block expiration anononly - block anonymous users only nocreate - disable account creation autoblock - block IP addresses used by the user noemail - block user from sending email through...
def block( self, reason=False, expiry=False, anononly=False, nocreate=False, autoblock=False, noemail=False, hidename=False, allowusertalk=False, reblock=False, ): """Block the user Params are the same as the API reason - block reason expiry - block expiration ...
(self, reason=False, expiry=False, anononly=False, nocreate=False, autoblock=False, noemail=False, hidename=False, allowusertalk=False, reblock=False)
[ 0.04096534848213196, -0.014936038292944431, 0.016694284975528717, 0.012615877203643322, -0.03418612852692604, -0.04498937726020813, -0.029364541172981262, -0.01149204932153225, -0.023546012118458748, 0.003548215376213193, -0.05332745611667633, -0.02468796633183956, -0.0174646507948637, 0.0...
7,273
wikitools3.user
getTalkPage
Convenience function to get an object for the user's talk page
def getTalkPage(self, check=True, followRedir=False): """Convenience function to get an object for the user's talk page""" return page.Page( self.site, ":".join([self.site.namespaces[3]["*"], self.name]), check=check, followRedir=False, )
(self, check=True, followRedir=False)
[ -0.0440998338162899, -0.02488836832344532, -0.05939977616071701, 0.021184535697102547, -0.007879297249019146, 0.03477102145552635, 0.04586521163582802, 0.02916335128247738, 0.004885077476501465, 0.006429783534258604, 0.042542148381471634, 0.0017502338159829378, 0.04351137578487396, 0.03728...
7,274
wikitools3.user
isBlocked
Determine if a user is blocked
def isBlocked(self, force=False): """Determine if a user is blocked""" if self.blocked is not None and not force: return self.blocked params = { "action": "query", "list": "blocks", "bkusers": self.name, "bkprop": "id", } req = api.APIRequest(self.site, params...
(self, force=False)
[ 0.09462814033031464, -0.021731257438659668, -0.007336507551372051, 0.057313982397317886, -0.04226111248135567, -0.0130387544631958, -0.011174812912940979, -0.01340977568179369, 0.010715452954173088, -0.028762996196746826, -0.04120104759931564, -0.019187109544873238, -0.037561506032943726, ...
7,275
wikitools3.user
setUserInfo
Sets basic user info
def setUserInfo(self): """Sets basic user info""" params = { "action": "query", "list": "users", "ususers": self.name, "usprop": "blockinfo|groups|editcount", } req = api.APIRequest(self.site, params) response = req.query(False) user = response["query"]["users"][0...
(self)
[ -0.01902574673295021, 0.00005628811049973592, 0.008702968247234821, 0.011853639967739582, -0.00041870452696457505, -0.04086041450500488, -0.009981026872992516, -0.05471774935722351, -0.027808301150798798, 0.022190462797880173, -0.03486805036664009, -0.02767721749842167, -0.02307059057056904,...
7,276
wikitools3.user
unblock
Unblock the user reason - reason for the log
def unblock(self, reason=False): """Unblock the user reason - reason for the log """ token = self.site.getToken("csrf") params = {"action": "unblock", "user": self.name, "token": token} if reason: params["reason"] = reason req = api.APIRequest(self.site, params, write=False) res ...
(self, reason=False)
[ 0.04620993137359619, 0.03361843153834343, 0.03751035034656525, 0.022559041157364845, -0.044307999312877655, -0.0547686330974102, -0.04934459924697876, 0.0006240718648768961, 0.004065822344273329, 0.024989290162920952, -0.06135495752096176, -0.046843912452459335, -0.036048680543899536, -0.0...
7,277
wikitools3.wiki
UserBlocked
Trying to edit while blocked
class UserBlocked(WikiError): """Trying to edit while blocked"""
null
[ -0.029621371999382973, -0.0339440256357193, -0.00857642013579607, 0.10023045539855957, -0.028794728219509125, -0.04126325994729996, 0.03091300092637539, -0.0007991957827471197, 0.00522248912602663, -0.019581103697419167, 0.03768114000558853, 0.013432947918772697, -0.011573000811040401, -0....
7,278
wikitools3.wiki
Wiki
A Wiki site
class Wiki: """A Wiki site""" def __init__( self, url="https://en.wikipedia.org/w/api.php", httpuser=None, httppass=None, preauth=False, ): """ url - A URL to the site's API, defaults to en.wikipedia httpuser - optional user name for HTTP Auth...
(url='https://en.wikipedia.org/w/api.php', httpuser=None, httppass=None, preauth=False)
[ -0.01870817318558693, -0.0008721535559743643, -0.05385500192642212, 0.059988830238580704, 0.00964544340968132, -0.010713751427829266, -0.06309663504362106, -0.007442377042025328, -0.033061329275369644, -0.01871839538216591, -0.012451669201254845, 0.03874533995985985, 0.02833828143775463, 0...
7,279
wikitools3.wiki
__eq__
null
def __eq__(self, other): if not isinstance(other, Wiki): return False if self.apibase == other.apibase: return True return False
(self, other)
[ -0.002797225257381797, -0.03483698144555092, -0.02451813593506813, 0.04726136103272438, -0.06393160670995712, -0.05773681774735451, -0.018949786201119423, 0.007134446874260902, 0.016200415790081024, 0.00342148938216269, -0.00022580633230973035, -0.027667732909321785, 0.05108959972858429, 0...
7,280
wikitools3.wiki
__hash__
null
def __hash__(self): return hash(self.apibase)
(self)
[ -0.007167326286435127, -0.0412500724196434, -0.00025125168031081557, 0.06583821773529053, -0.014199738390743732, -0.060880113393068314, -0.031451914459466934, -0.025347039103507996, 0.012428986839950085, -0.04394835978746414, -0.026746775954961777, 0.0037206856068223715, 0.01770751178264618,...
7,281
wikitools3.wiki
__init__
url - A URL to the site's API, defaults to en.wikipedia httpuser - optional user name for HTTP Auth httppass - password for HTTP Auth, leave out to enter interactively preauth - true to send headers for HTTP Auth on the first request instead of relying on the negot...
def __init__( self, url="https://en.wikipedia.org/w/api.php", httpuser=None, httppass=None, preauth=False, ): """ url - A URL to the site's API, defaults to en.wikipedia httpuser - optional user name for HTTP Auth httppass - password for HTTP Auth, leave out to enter interactivel...
(self, url='https://en.wikipedia.org/w/api.php', httpuser=None, httppass=None, preauth=False)
[ -0.047407880425453186, -0.005034585949033499, -0.053156495094299316, 0.047407880425453186, -0.006758260540664196, 0.005357490386813879, -0.026087068021297455, -0.010232897475361824, -0.03716588392853737, 0.038130052387714386, 0.024249693378806114, 0.0861564502120018, 0.011724626645445824, ...
7,282
wikitools3.wiki
__ne__
null
def __ne__(self, other): if not isinstance(other, Wiki): return True if self.apibase == other.apibase: return False return True
(self, other)
[ -0.018138784915208817, -0.004462404176592827, -0.006826141849160194, 0.04907111078500748, -0.10823684930801392, -0.05878017842769623, -0.03238693252205849, 0.01453731581568718, 0.04076407104730606, 0.009638967923820019, 0.006948819383978844, -0.028338566422462463, 0.02702416107058525, 0.02...
7,283
wikitools3.wiki
__repr__
null
def __repr__(self): if self.username: user = " User:" + self.username else: user = " not logged in" return ( "<" + self.__module__ + "." + self.__class__.__name__ + " " + repr(self.apibase) + user + ">" )
(self)
[ -0.030440904200077057, -0.030641894787549973, 0.06281862407922745, 0.02543441765010357, 0.07038316875696182, -0.06680189073085785, 0.02293117344379425, -0.009327780455350876, 0.046300869435071945, -0.02647591196000576, 0.014736248180270195, 0.014571801759302616, -0.025306513532996178, 0.05...
7,284
wikitools3.wiki
__str__
null
def __str__(self): if self.username: user = " - using User:" + self.username else: user = " - not logged in" return self.domain + user
(self)
[ -0.05076637864112854, 0.008067216724157333, 0.037667661905288696, 0.03584446385502815, 0.05097879096865654, -0.02812683954834938, 0.028480859473347664, -0.03262288495898247, 0.08453983068466187, -0.02589651755988598, 0.00018005204037763178, -0.01648845337331295, -0.036393191665410995, 0.00...
7,285
wikitools3.wiki
getToken
Get a token For wikis with MW 1.24 or newer: type (string) - csrf, deleteglobalaccount, patrol, rollback, setglobalaccountstatus, userrights, watch For older wiki versions, only csrf (edit, move, etc.) tokens are supported
def getToken(self, type): """Get a token For wikis with MW 1.24 or newer: type (string) - csrf, deleteglobalaccount, patrol, rollback, setglobalaccountstatus, userrights, watch For older wiki versions, only csrf (edit, move, etc.) tokens are supported """ if self.newtoken: params = { ...
(self, type)
[ 0.03621804341673851, -0.0006226133555173874, 0.020071757957339287, 0.021608617156744003, 0.023015862330794334, 0.002102766651660204, 0.008360146544873714, -0.056178703904151917, -0.041809991002082825, 0.008397179655730724, 0.06177065148949623, 0.006147438660264015, 0.009498904459178448, 0....
7,286
wikitools3.wiki
isLoggedIn
Verify that we are a logged in user username - specify a username to check against
def isLoggedIn(self, username=False): """Verify that we are a logged in user username - specify a username to check against """ data = { "action": "query", "meta": "userinfo", } if self.maxlag < 120: data["maxlag"] = 120 req = api.APIRequest(self, data) info = req...
(self, username=False)
[ -0.008896479383111, -0.00719458470121026, -0.020404085516929626, 0.03597758710384369, 0.01958344504237175, -0.009698468260467052, 0.004637080244719982, 0.014100080356001854, 0.005958962719887495, 0.0015188826946541667, -0.010966729372739792, -0.023052513599395752, 0.02775253914296627, -0.0...
7,287
wikitools3.wiki
login
Login to the site remember - saves cookies to a file - the filename will be: hash(username - apibase).cookies the cookies will be saved in the current directory, change cookiepath to use a different location force - forces login over the API even if a cookie file exists ...
def login( self, username, password=False, remember=False, force=False, verify=True, domain=None, ): """Login to the site remember - saves cookies to a file - the filename will be: hash(username - apibase).cookies the cookies will be saved in the current directory, change coo...
(self, username, password=False, remember=False, force=False, verify=True, domain=None)
[ -0.0266495980322361, -0.008710107766091824, -0.0020391352009028196, 0.07642164081335068, 0.02753138728439808, -0.03292009234428406, -0.06290089339017868, 0.009273472242057323, 0.0015970163512974977, -0.027688149362802505, 0.0044383336789906025, 0.016391461715102196, 0.011913938447833061, 0...
7,288
wikitools3.wiki
logout
null
def logout(self): params = {"action": "logout"} if self.maxlag < 120: params["maxlag"] = 120 cookiefile = ( self.cookiepath + str(hash(self.username + " - " + self.apibase)) + ".cookies" ) try: os.remove(cookiefile) except: pass req = api.APIRe...
(self)
[ -0.05517717823386192, 0.01760060526430607, 0.010827472433447838, -0.000439716997789219, -0.012039003893733025, -0.026806341484189034, -0.0947093740105629, 0.060290418565273285, -0.021960211917757988, 0.011562023311853409, -0.02816096693277359, 0.026958974078297615, 0.026310279965400696, 0....
7,289
wikitools3.wiki
setAssert
Set an assertion value This only makes a difference on sites with the AssertEdit extension on others it will be silently ignored This is only checked on edits, so only applied to write queries Set to None (the default) to not use anything http://www.mediawiki.org/wiki/Extension...
def setAssert(self, value): """Set an assertion value This only makes a difference on sites with the AssertEdit extension on others it will be silently ignored This is only checked on edits, so only applied to write queries Set to None (the default) to not use anything http://www.mediawiki.org/w...
(self, value)
[ 0.01961382105946541, 0.012066725641489029, 0.04388527572154999, 0.03253444656729698, -0.003760609310120344, -0.03839961811900139, 0.019182557240128517, -0.028963591903448105, 0.0020743729546666145, -0.0003121262707281858, 0.02204614132642746, 0.01864779181778431, 0.024944225326180458, 0.03...
7,290
wikitools3.wiki
setMaxlag
Set the maximum server lag to allow If the lag is > the maxlag value, all requests will wait Setting to a negative number will disable maxlag checks
def setMaxlag(self, maxlag=5): """Set the maximum server lag to allow If the lag is > the maxlag value, all requests will wait Setting to a negative number will disable maxlag checks """ try: int(maxlag) except: raise WikiError("maxlag must be an integer") self.maxlag = int(m...
(self, maxlag=5)
[ 0.01306526642292738, 0.027037102729082108, -0.058056000620126724, 0.03064560517668724, -0.04141778498888016, 0.01482507772743702, -0.01675376109778881, -0.005119451321661472, -0.04187995567917824, -0.037364885210990906, -0.05019906535744667, 0.01448733638972044, -0.0357828326523304, -0.010...
7,291
wikitools3.wiki
setSiteinfo
Retrieves basic siteinfo Called when constructing, or after login if the first call failed
def setSiteinfo(self): """Retrieves basic siteinfo Called when constructing, or after login if the first call failed """ params = { "action": "query", "meta": "siteinfo|tokens", "siprop": "general|namespaces|namespacealiases", } if self.maxlag < 120: params["m...
(self)
[ -0.008519409224390984, -0.00560033367946744, -0.01205867063254118, 0.01552798692137003, -0.00010907186515396461, 0.0004074347671121359, -0.024061383679509163, -0.032846588641405106, 0.004914864432066679, 0.02482612617313862, -0.016619142144918442, 0.012030691839754581, 0.008519409224390984, ...
7,292
wikitools3.wiki
setUserAgent
Function to set a different user-agent
def setUserAgent(self, useragent): """Function to set a different user-agent""" self.useragent = str(useragent) return self.useragent
(self, useragent)
[ -0.03061477467417717, -0.023977136239409447, -0.005546154920011759, 0.0017470387974753976, -0.014943559654057026, -0.03198134899139404, 0.00973461102694273, 0.016700580716133118, 0.009038014337420464, -0.03858349099755287, 0.0015263018431141973, 0.0019045495428144932, -0.02177642285823822, ...
7,293
wikitools3.wiki
WikiCookieJar
null
class WikiCookieJar(http.cookiejar.FileCookieJar): def save(self, site, filename=None, ignore_discard=False, ignore_expires=False): if not filename: filename = self.filename old_umask = os.umask(0o077) f = open(filename, "w") f.write("") content = "" for c...
(filename=None, delayload=False, policy=None)
[ 0.011462807655334473, 0.01063031330704689, -0.04724177345633507, 0.06231815367937088, -0.006627936381846666, 0.0031081316992640495, -0.04636353626847267, 0.03179945796728134, -0.014527485705912113, 0.015067234635353088, 0.03626382350921631, 0.07325951009988785, -0.005795442033559084, 0.023...
7,294
http.cookiejar
__init__
Cookies are NOT loaded from the named file until either the .load() or .revert() method is called.
def __init__(self, filename=None, delayload=False, policy=None): """ Cookies are NOT loaded from the named file until either the .load() or .revert() method is called. """ CookieJar.__init__(self, policy) if filename is not None: filename = os.fspath(filename) self.filename = filenam...
(self, filename=None, delayload=False, policy=None)
[ -0.011377803981304169, 0.012372489087283611, -0.03835646063089371, 0.041427772492170334, 0.0008479910320602357, -0.0002287667157361284, -0.018846670165657997, 0.04373125359416008, 0.015539776533842087, 0.03703021630644798, 0.03629728779196739, 0.09179025888442993, -0.02010311372578144, 0.0...
7,295
http.cookiejar
__iter__
null
def __iter__(self): return deepvalues(self._cookies)
(self)
[ -0.010246144607663155, -0.016795312985777855, -0.06952323019504547, -0.0004412115376908332, -0.025092599913477898, 0.02753494493663311, -0.02644759975373745, -0.010154138319194317, 0.08504718542098999, 0.04162025824189186, 0.00009370517364004627, 0.04302544519305229, 0.017615005373954773, ...
7,296
http.cookiejar
__len__
Return number of contained cookies.
def __len__(self): """Return number of contained cookies.""" i = 0 for cookie in self: i = i + 1 return i
(self)
[ -0.04246267303824425, -0.028845448046922684, -0.06538979709148407, 0.054740216583013535, 0.01081068441271782, 0.06457582116127014, -0.022571012377738953, -0.02955768257379532, 0.019298130646348, 0.0071562486700713634, -0.0063210707157850266, 0.015355410985648632, 0.015304537490010262, 0.00...
7,297
http.cookiejar
__repr__
null
def __repr__(self): r = [] for cookie in self: r.append(repr(cookie)) return "<%s[%s]>" % (self.__class__.__name__, ", ".join(r))
(self)
[ -0.03339311107993126, -0.016504941508173943, 0.03130277618765831, -0.0034381665755063295, 0.035605382174253464, -0.012785885483026505, -0.004572608973830938, -0.027278879657387733, 0.058250684291124344, 0.003366311313584447, -0.021164648234844208, 0.027749205008149147, -0.0077734352089464664...
7,298
http.cookiejar
__str__
null
def __str__(self): r = [] for cookie in self: r.append(str(cookie)) return "<%s[%s]>" % (self.__class__.__name__, ", ".join(r))
(self)
[ -0.05517590418457985, -0.012045689858496189, 0.016381438821554184, -0.000785635958891362, 0.038287460803985596, -0.019598284736275673, 0.003955496940761805, -0.03451116383075714, 0.0669943168759346, -0.02723829448223114, -0.014536997303366661, 0.034860819578170776, -0.015883177518844604, 0...
7,299
http.cookiejar
_cookie_attrs
Return a list of cookie-attributes to be returned to server. like ['foo="bar"; $Path="/"', ...] The $Version attribute is also added when appropriate (currently only once per request).
def _cookie_attrs(self, cookies): """Return a list of cookie-attributes to be returned to server. like ['foo="bar"; $Path="/"', ...] The $Version attribute is also added when appropriate (currently only once per request). """ # add cookies in order of most specific (ie. longest) path first c...
(self, cookies)
[ -0.03210444748401642, 0.032912567257881165, -0.050397370010614395, 0.011515725404024124, 0.0015129313105717301, 0.007989378646016121, -0.00739247165620327, 0.0032370761036872864, 0.058147985488176346, -0.008783725090324879, -0.008251099847257137, 0.0877913385629654, 0.005771637428551912, 0...
7,300
http.cookiejar
_cookie_from_cookie_tuple
null
def _cookie_from_cookie_tuple(self, tup, request): # standard is dict of standard cookie-attributes, rest is dict of the # rest of them name, value, standard, rest = tup domain = standard.get("domain", Absent) path = standard.get("path", Absent) port = standard.get("port", Absent) expires = ...
(self, tup, request)
[ -0.012810103595256805, 0.04745650663971901, -0.026526767760515213, 0.015244022943079472, -0.012652439996600151, -0.03616390749812126, -0.01360827125608921, 0.07382561266422272, 0.023550882935523987, -0.025009263306856155, 0.03007418103516102, 0.14244835078716278, -0.006119287572801113, 0.0...
7,301
http.cookiejar
_cookies_for_domain
null
def _cookies_for_domain(self, domain, request): cookies = [] if not self._policy.domain_return_ok(domain, request): return [] _debug("Checking %s for cookies to return", domain) cookies_by_path = self._cookies[domain] for path in cookies_by_path.keys(): if not self._policy.path_retur...
(self, domain, request)
[ -0.010511948727071285, -0.001910761115141213, -0.0939975157380104, 0.0361420102417469, -0.00435198238119483, 0.027760740369558334, -0.04961569234728813, -0.04904986917972565, 0.040421053767204285, 0.016912832856178284, 0.03152700513601303, 0.02641690894961357, 0.03907722234725952, 0.010008...
7,302
http.cookiejar
_cookies_for_request
Return a list of cookies to be returned to server.
def _cookies_for_request(self, request): """Return a list of cookies to be returned to server.""" cookies = [] for domain in self._cookies.keys(): cookies.extend(self._cookies_for_domain(domain, request)) return cookies
(self, request)
[ -0.04871998354792595, -0.009943927638232708, -0.07744688540697098, 0.01668720878660679, -0.035443875938653946, 0.05899713188409805, -0.05422684922814369, -0.03446175903081894, 0.042897436767816544, 0.03682936355471611, 0.022465910762548447, 0.012530751526355743, 0.028095541521906853, 0.022...
7,303
http.cookiejar
_cookies_from_attrs_set
null
def _cookies_from_attrs_set(self, attrs_set, request): cookie_tuples = self._normalized_cookie_tuples(attrs_set) cookies = [] for tup in cookie_tuples: cookie = self._cookie_from_cookie_tuple(tup, request) if cookie: cookies.append(cookie) return cookies
(self, attrs_set, request)
[ -0.02775171399116516, -0.014928138814866543, -0.045194629579782486, 0.002285146852955222, -0.03288827836513519, 0.028019243851304054, -0.012404445558786392, 0.026360560208559036, 0.04876168817281723, 0.02402413822710514, 0.002530382014811039, 0.06067566201090813, 0.01295733917504549, 0.057...
7,304
http.cookiejar
_normalized_cookie_tuples
Return list of tuples containing normalised cookie information. attrs_set is the list of lists of key,value pairs extracted from the Set-Cookie or Set-Cookie2 headers. Tuples are name, value, standard, rest, where name and value are the cookie name and value, standard is a dictionary c...
def _normalized_cookie_tuples(self, attrs_set): """Return list of tuples containing normalised cookie information. attrs_set is the list of lists of key,value pairs extracted from the Set-Cookie or Set-Cookie2 headers. Tuples are name, value, standard, rest, where name and value are the cookie name ...
(self, attrs_set)
[ -0.01706147938966751, 0.03823721408843994, -0.04929305240511894, 0.015862300992012024, -0.011319072917103767, -0.01314221415668726, -0.007687415461987257, 0.03769124671816826, 0.03349899873137474, -0.02435404434800148, -0.02624543011188507, 0.1108313724398613, 0.002917513018473983, 0.07409...
7,305
http.cookiejar
_process_rfc2109_cookies
null
def _process_rfc2109_cookies(self, cookies): rfc2109_as_ns = getattr(self._policy, 'rfc2109_as_netscape', None) if rfc2109_as_ns is None: rfc2109_as_ns = not self._policy.rfc2965 for cookie in cookies: if cookie.version == 1: cookie.rfc2109 = True if rfc2109_as_ns: ...
(self, cookies)
[ -0.047983866184949875, 0.029630834236741066, -0.06681566685438156, 0.024736693128943443, -0.044685639441013336, 0.01998441107571125, 0.0010589564917609096, -0.0032006974797695875, 0.04741642624139786, 0.0036351413000375032, 0.01396426185965538, 0.017909720540046692, -0.006858004257082939, ...
7,306
http.cookiejar
add_cookie_header
Add correct Cookie: header to request (urllib.request.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true.
def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib.request.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. """ _debug("add_cookie_header") self._cookies_lock.acquire() try: self._policy._now = self._now = int(time....
(self, request)
[ -0.07893279939889908, 0.045433565974235535, -0.06299517303705215, 0.053666748106479645, -0.03463223576545715, -0.005433711223304272, -0.009894924238324165, 0.030458996072411537, -0.01574879325926304, -0.028683951124548912, 0.0370681993663311, 0.0348966047167778, -0.014578019268810749, 0.05...
7,307
http.cookiejar
clear
Clear some cookies. Invoking this method without arguments will clear all cookies. If given a single argument, only cookies belonging to that domain will be removed. If given two arguments, cookies belonging to the specified path within that domain are removed. If given three argumen...
def clear(self, domain=None, path=None, name=None): """Clear some cookies. Invoking this method without arguments will clear all cookies. If given a single argument, only cookies belonging to that domain will be removed. If given two arguments, cookies belonging to the specified path within that d...
(self, domain=None, path=None, name=None)
[ -0.012722080573439598, 0.025304261595010757, -0.0042385077103972435, -0.019655833020806313, -0.03403047099709511, -0.013299164362251759, -0.10863170027732849, -0.0010405000066384673, 0.07386676222085953, 0.06001674383878708, 0.005652800668030977, 0.02504195086658001, 0.03864714503288269, 0...
7,308
http.cookiejar
clear_expired_cookies
Discard all expired cookies. You probably don't need to call this method: expired cookies are never sent back to the server (provided you're using DefaultCookiePolicy), this method is called by CookieJar itself every so often, and the .save() method won't save expired cookies anyway (un...
def clear_expired_cookies(self): """Discard all expired cookies. You probably don't need to call this method: expired cookies are never sent back to the server (provided you're using DefaultCookiePolicy), this method is called by CookieJar itself every so often, and the .save() method won't save exp...
(self)
[ -0.017374278977513313, 0.025753553956747055, -0.02664591558277607, 0.01428670808672905, -0.005769117269665003, -0.01815955713391304, -0.07802809029817581, 0.000696042028721422, 0.040513213723897934, 0.05372016504406929, -0.004020088817924261, 0.015205840580165386, 0.05439835786819458, 0.04...
7,309
http.cookiejar
clear_session_cookies
Discard all session cookies. Note that the .save() method won't save session cookies anyway, unless you ask otherwise by passing a true ignore_discard argument.
def clear_session_cookies(self): """Discard all session cookies. Note that the .save() method won't save session cookies anyway, unless you ask otherwise by passing a true ignore_discard argument. """ self._cookies_lock.acquire() try: for cookie in self: if cookie.discard: ...
(self)
[ -0.05468646064400673, -0.00405931007117033, -0.026130709797143936, 0.006440420635044575, -0.03166613355278969, -0.032720498740673065, -0.08990229666233063, 0.03662165254354477, 0.05690063163638115, 0.053948406130075455, -0.022088972851634026, 0.0020230652298778296, 0.0378166027367115, 0.04...
7,310
http.cookiejar
extract_cookies
Extract cookies from response, where allowable given the request.
def extract_cookies(self, response, request): """Extract cookies from response, where allowable given the request.""" _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() try: for cookie in self.make_cookies(response, request): if self._policy.set_ok(cookie, re...
(self, response, request)
[ -0.04342737793922424, 0.04303225874900818, -0.08110754191875458, 0.03367507830262184, -0.01529297512024641, 0.025036297738552094, -0.00009653522283770144, 0.03965577110648155, -0.016693858429789543, 0.05355684086680412, 0.028610344976186752, 0.08247251063585281, 0.06300382316112518, 0.0209...
7,311
wikitools3.wiki
load
null
def load(self, site, filename, ignore_discard, ignore_expires): f = open(filename, "r") cookies = f.read().split("|~|") saved = cookies[len(cookies) - 2] if ( int(time.time()) - int(saved) > 1296000 ): # 15 days, not sure when the cookies actually expire... f.close() os.remo...
(self, site, filename, ignore_discard, ignore_expires)
[ 0.002845869865268469, 0.0019098796183243394, -0.06442369520664215, 0.03822056204080582, 0.0102074621245265, -0.0022911664564162493, -0.00014391569129657, 0.007933522574603558, 0.011208915151655674, 0.03811030834913254, -0.023226341232657433, 0.04255712404847145, -0.036364659667015076, 0.01...
7,312
http.cookiejar
make_cookies
Return sequence of Cookie objects extracted from response object.
def make_cookies(self, response, request): """Return sequence of Cookie objects extracted from response object.""" # get cookie-attributes for RFC 2965 and Netscape protocols headers = response.info() rfc2965_hdrs = headers.get_all("Set-Cookie2", []) ns_hdrs = headers.get_all("Set-Cookie", []) s...
(self, response, request)
[ -0.055724192410707474, 0.03985288739204407, -0.06612396985292435, 0.011428115889430046, -0.04819599166512489, 0.04000810533761978, -0.034769412130117416, 0.011903478763997555, 0.030365027487277985, -0.004649341572076082, 0.030636664479970932, 0.102445587515831, 0.01982942968606949, 0.04408...
7,313
http.cookiejar
revert
Clear all cookies and reload cookies from a saved file. Raises LoadError (or OSError) if reversion is not successful; the object's state will not be altered if this happens.
def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. Raises LoadError (or OSError) if reversion is not successful; the object's state will not be altered if this happens. """ if filename is None: if...
(self, filename=None, ignore_discard=False, ignore_expires=False)
[ -0.01741613633930683, -0.023943882435560226, -0.022428670898079872, -0.004453139379620552, -0.002404959639534354, -0.04154501482844353, -0.05232769250869751, 0.03890220448374748, 0.05831806734204292, 0.029599502682685852, -0.019997281953692436, 0.010923625901341438, -0.03144947066903114, 0...
7,314
wikitools3.wiki
save
null
def save(self, site, filename=None, ignore_discard=False, ignore_expires=False): if not filename: filename = self.filename old_umask = os.umask(0o077) f = open(filename, "w") f.write("") content = "" for c in self: if not ignore_discard and c.discard: continue ...
(self, site, filename=None, ignore_discard=False, ignore_expires=False)
[ 0.04807652160525322, 0.020941996946930885, -0.08226677030324936, 0.03227619454264641, 0.05081624537706375, -0.05494459345936775, -0.05393127351999283, -0.0462750568985939, -0.011456172913312912, 0.01007692888379097, -0.04312250018119812, -0.01607242040336132, -0.025501947849988937, -0.0127...
7,315
http.cookiejar
set_cookie
Set a cookie, without checking whether or not it should be set.
def set_cookie(self, cookie): """Set a cookie, without checking whether or not it should be set.""" c = self._cookies self._cookies_lock.acquire() try: if cookie.domain not in c: c[cookie.domain] = {} c2 = c[cookie.domain] if cookie.path not in c2: c2[cookie.path] = {} c3...
(self, cookie)
[ -0.03575143963098526, 0.05797530710697174, -0.008217813447117805, 0.08123975992202759, -0.04753232002258301, 0.0018953465623781085, -0.01866544783115387, 0.05455625057220459, 0.02833728864789009, -0.007009995169937611, 0.006276012863963842, 0.053032539784908295, -0.00226001488044858, 0.053...
7,316
http.cookiejar
set_cookie_if_ok
Set a cookie if policy says it's OK to do so.
def set_cookie_if_ok(self, cookie, request): """Set a cookie if policy says it's OK to do so.""" self._cookies_lock.acquire() try: self._policy._now = self._now = int(time.time()) if self._policy.set_ok(cookie, request): self.set_cookie(cookie) finally: self._cookies_...
(self, cookie, request)
[ -0.035191431641578674, 0.044098228216171265, -0.052394967526197433, 0.0810849592089653, 0.005843450780957937, -0.02497737482190132, 0.011826342903077602, 0.04758425056934357, -0.010867685079574585, 0.014257845468819141, 0.02049783244729042, 0.05860009416937828, 0.042250633239746094, 0.0209...
7,317
http.cookiejar
set_policy
null
def set_policy(self, policy): self._policy = policy
(self, policy)
[ 0.017110897228121758, 0.0391526073217392, -0.025715326890349388, 0.020392661914229393, 0.005306337494403124, -0.004636922385543585, 0.025894926860928535, 0.020180409774184227, 0.020049791783094406, 0.030237959697842598, -0.05234497785568237, 0.04581410065293312, 0.0004306296759750694, 0.01...
7,318
wikitools3.wiki
WikiError
Base class for errors
class WikiError(Exception): """Base class for errors"""
null
[ -0.04274434596300125, -0.05308682844042778, -0.02410382591187954, 0.05229654163122177, -0.03552865982055664, -0.042881786823272705, -0.019705694168806076, 0.024275626987218857, 0.03676563501358032, -0.006927917245775461, 0.08232753723859787, 0.023725861683487892, 0.05906553938984871, 0.020...
7,328
poster3.encode
multipart_encode
Encode ``params`` as multipart/form-data. ``params`` should be a sequence of (name, value) pairs or MultipartParam objects, or a mapping of names to values. Values are either strings parameter values, or file-like objects to use as the parameter value. The file-like objects must support .read() and ei...
def multipart_encode(params, boundary=None, cb=None): """Encode ``params`` as multipart/form-data. ``params`` should be a sequence of (name, value) pairs or MultipartParam objects, or a mapping of names to values. Values are either strings parameter values, or file-like objects to use as the parame...
(params, boundary=None, cb=None)
[ 0.017313813790678978, 0.09387423098087311, -0.053686246275901794, 0.036736730486154556, -0.05265086516737938, -0.02089928835630417, -0.004151097033172846, 0.0076886373572051525, 0.01768770068883896, -0.01653728075325489, 0.038040537387132645, 0.016757776960730553, -0.003482415806502104, -0...
7,329
wikitools3.page
namespaceDetect
Detect the namespace of a given title title - the page title site - the wiki object the page is on
def namespaceDetect(title, site): """Detect the namespace of a given title title - the page title site - the wiki object the page is on """ bits = title.split(":", 1) if len(bits) == 1 or bits[0] == "": return 0 else: nsprefix = bits[ 0 ].lower() # wp:Foo...
(title, site)
[ 0.00008061548578552902, 0.006360831204801798, 0.023811180144548416, -0.022124631330370903, 0.041130051016807556, 0.016874564811587334, 0.04649799317121506, -0.010690548457205296, 0.03924401476979256, 0.01611289754509926, -0.019821492955088615, 0.00610694196075201, 0.0027066401671618223, -0...
7,333
urllib.parse
quote_plus
Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'.
def quote_plus(string, safe='', encoding=None, errors=None): """Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'. """ # Check if ' ' in stri...
(string, safe='', encoding=None, errors=None)
[ -0.04816910997033119, 0.01683487929403782, 0.014273615553975105, 0.10161703079938889, 0.029311267659068108, -0.03488527238368988, -0.0016496271127834916, -0.008482555858790874, 0.022313376888632774, -0.039903610944747925, 0.05820579081773758, -0.02337261103093624, -0.005083456169813871, 0....
7,335
wikitools3.api
resultCombine
Experimental-ish result-combiner thing If the result isn't something from action=query, this will just explode, but that shouldn't happen hopefully?
def resultCombine(type, old, new): """Experimental-ish result-combiner thing If the result isn't something from action=query, this will just explode, but that shouldn't happen hopefully? """ ret = old if type in new["query"]: # Basic list, easy ret["query"][type].extend(new["query"][t...
(type, old, new)
[ -0.01835756190121174, -0.01505248248577118, -0.04954027011990547, -0.014801009558141232, -0.0356912687420845, 0.017773784697055817, -0.007005332037806511, -0.0737176463007927, 0.024231264367699623, -0.03163176774978638, 0.02507549710571766, 0.026296939700841904, -0.0032691550441086292, 0.0...
7,340
wikitools3.api
urlencode
Hack of urllib's urlencode function, which can handle utf-8, but for unknown reasons, chooses not to by trying to encode everything as ascii
def urlencode(query, doseq=0): """ Hack of urllib's urlencode function, which can handle utf-8, but for unknown reasons, chooses not to by trying to encode everything as ascii """ if hasattr(query, "items"): # mapping objects query = query.items() else: # it's a bothe...
(query, doseq=0)
[ -0.03222358599305153, 0.05501587688922882, -0.04769233241677284, 0.018014127388596535, -0.04947856441140175, 0.021684829145669937, -0.030437353998422623, -0.04244082048535347, 0.0614820271730423, -0.058695510029792786, -0.023220986127853394, 0.06526883691549301, 0.02261366881430149, 0.0573...
7,347
requests_auth_aws_sigv4
AWSSigV4
null
class AWSSigV4(AuthBase): def __init__(self, service, **kwargs): ''' Create authentication mechanism :param service: AWS Service identifier, for example `ec2`. This is required. :param region: AWS Region, for example `us-east-1`. If not provided, it will be set using ...
(service, **kwargs)
[ -0.008218237198889256, -0.04168887436389923, -0.08435966819524765, 0.03257410228252411, -0.026661241427063942, -0.04448520764708519, -0.053450558334589005, 0.039660997688770294, -0.0203854963183403, -0.018741849809885025, -0.00031985752866603434, 0.054219018667936325, 0.010849139653146267, ...
7,348
requests_auth_aws_sigv4
__call__
Called to add authentication information to request :param r: `requests.models.PreparedRequest` object to modify :returns: `requests.models.PreparedRequest`, modified to add authentication
def __call__(self, r): ''' Called to add authentication information to request :param r: `requests.models.PreparedRequest` object to modify :returns: `requests.models.PreparedRequest`, modified to add authentication ''' # Create a date for headers and the credential string t = dat...
(self, r)
[ -0.024579443037509918, -0.010806649923324585, -0.09293916821479797, 0.045836806297302246, -0.036246273666620255, -0.03844122216105461, -0.057266343384981155, 0.023373210802674294, -0.02770378068089485, -0.016303902491927147, -0.005596124101430178, 0.047023262828588486, 0.021356234326958656, ...
7,349
requests_auth_aws_sigv4
__init__
Create authentication mechanism :param service: AWS Service identifier, for example `ec2`. This is required. :param region: AWS Region, for example `us-east-1`. If not provided, it will be set using the environment variables `AWS_DEFAULT_REGION` or using boto3, if available. ...
def __init__(self, service, **kwargs): ''' Create authentication mechanism :param service: AWS Service identifier, for example `ec2`. This is required. :param region: AWS Region, for example `us-east-1`. If not provided, it will be set using the environment variables `AWS_DEFAULT_REGION` or ...
(self, service, **kwargs)
[ 0.013355843722820282, -0.09056386351585388, -0.025432316586375237, -0.007584142033010721, 0.01016711164265871, -0.04621238261461258, -0.02783598192036152, 0.06842689216136932, 0.005980083718895912, -0.01161124836653471, 0.009304506704211235, 0.04396379366517067, 0.008596976287662983, -0.03...
7,350
requests.auth
AuthBase
Base class that all auth implementations derive from
class AuthBase: """Base class that all auth implementations derive from""" def __call__(self, r): raise NotImplementedError("Auth hooks must be callable.")
()
[ -0.04858025163412094, -0.04959611967206001, -0.020099671557545662, 0.07038512825965881, 0.008925124071538448, -0.03620843216776848, -0.011283389292657375, 0.003793631447479129, 0.00036394372000359, -0.026648391038179398, 0.0639633908867836, 0.022857027128338814, -0.008458007127046585, -0.0...
7,351
requests.auth
__call__
null
def __call__(self, r): raise NotImplementedError("Auth hooks must be callable.")
(self, r)
[ -0.05539315193891525, -0.04407808929681778, -0.04103821888566017, 0.11065120249986649, 0.02401495911180973, -0.0018323649419471622, -0.013493637554347515, 0.03342166170477867, 0.004694907460361719, -0.023356320336461067, 0.06123645603656769, 0.024031847715377808, 0.025771327316761017, -0.0...
7,359
requests_auth_aws_sigv4
sign_msg
Sign message using key
def sign_msg(key, msg): ''' Sign message using key ''' return hmac.new(key, msg.encode('utf-8'), hashlib.sha256).digest()
(key, msg)
[ -0.002257063053548336, -0.034068528562784195, -0.018521159887313843, 0.06847160309553146, 0.0006661995430476964, -0.03196828439831734, -0.009534726850688457, 0.02328852377831936, 0.05271049588918686, -0.025165731087327003, 0.04665139317512512, 0.04546187445521355, 0.007127812597900629, -0....
7,362
enum
Enum
Generic enumeration. Derive from this class to define new enumerations.
class Enum(metaclass=EnumMeta): """ Generic enumeration. Derive from this class to define new enumerations. """ def __new__(cls, value): # all enum instances are actually created during class construction # without calling this method; this method is called by the metaclass' ...
(value, names=None, *, module=None, qualname=None, type=None, start=1)
[ 0.08282136172056198, -0.04529804363846779, -0.06207510083913803, -0.0041328840889036655, 0.0032479967921972275, -0.011672328226268291, 0.026475008577108383, -0.0587196871638298, 0.0007550952723249793, -0.0766424909234047, -0.031180769205093384, 0.053809329867362976, 0.04194263368844986, 0....
7,363
uuid
SafeUUID
An enumeration.
class SafeUUID(Enum): safe = 0 unsafe = -1 unknown = None
(value, names=None, *, module=None, qualname=None, type=None, start=1)
[ 0.03551899269223213, -0.01965745911002159, -0.04202629253268242, 0.01280276756733656, 0.029791217297315598, -0.05863345414400101, 0.029875947162508965, -0.02243661694228649, -0.0029909841250628233, -0.061649858951568604, -0.003389216959476471, 0.09320347011089325, 0.0017094362992793322, 0....
7,364
uuid
UUID
Instances of the UUID class represent UUIDs as specified in RFC 4122. UUID objects are immutable, hashable, and usable as dictionary keys. Converting a UUID to a string with str() yields something in the form '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts five possible forms: a si...
class UUID: """Instances of the UUID class represent UUIDs as specified in RFC 4122. UUID objects are immutable, hashable, and usable as dictionary keys. Converting a UUID to a string with str() yields something in the form '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts five p...
(hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=<SafeUUID.unknown: None>)
[ 0.04629214107990265, -0.0047399080358445644, -0.05191602557897568, 0.04274573177099228, 0.04494912177324295, -0.050992701202631, 0.01781596802175045, 0.046418048441410065, -0.032673101872205734, -0.07848259061574936, 0.02224372886121273, 0.08998218178749084, 0.03964000567793846, 0.05544144...
7,365
uuid
__eq__
null
def __eq__(self, other): if isinstance(other, UUID): return self.int == other.int return NotImplemented
(self, other)
[ 0.012624919414520264, -0.04841262847185135, -0.012599258683621883, 0.05826622620224953, 0.001173963537439704, -0.05395527556538582, 0.0024056630209088326, 0.03568506985902786, 0.0010055671446025372, -0.03484683111310005, 0.020682286471128464, -0.01496856939047575, 0.0314425490796566, 0.065...
7,366
uuid
__ge__
null
def __ge__(self, other): if isinstance(other, UUID): return self.int >= other.int return NotImplemented
(self, other)
[ 0.00310833309777081, -0.039171405136585236, -0.03327518701553345, 0.058893829584121704, 0.0021736968774348497, -0.04043610021471977, 0.014894362539052963, 0.016543595120310783, -0.011937707662582397, -0.06743907928466797, 0.03411262109875679, -0.014116745442152023, 0.02797713316977024, 0.0...
7,367
uuid
__getstate__
null
def __getstate__(self): d = {'int': self.int} if self.is_safe != SafeUUID.unknown: # is_safe is a SafeUUID instance. Return just its value, so that # it can be un-pickled in older Python versions without SafeUUID. d['is_safe'] = self.is_safe.value return d
(self)
[ 0.03340638428926468, -0.012686318717896938, -0.012502058409154415, 0.013653685338795185, 0.0724511370062828, -0.020065942779183388, 0.0215953029692173, 0.001831086352467537, -0.000368808425264433, -0.08431749790906906, -0.0029343445785343647, 0.06725499778985977, -0.02485670894384384, -0.0...
7,368
uuid
__gt__
null
def __gt__(self, other): if isinstance(other, UUID): return self.int > other.int return NotImplemented
(self, other)
[ -0.007426389027386904, -0.029688483104109764, -0.03786604851484299, 0.0380367673933506, 0.014212572015821934, -0.045036353170871735, 0.008070862852036953, 0.021067043766379356, -0.013751623220741749, -0.07716615498065948, 0.034690625965595245, 0.0023602258879691362, 0.026274051517248154, -...
7,369
uuid
__hash__
null
def __hash__(self): return hash(self.int)
(self)
[ 0.0067759850062429905, -0.035083528608083725, 0.02017386071383953, 0.07529798150062561, 0.021839745342731476, -0.047477707266807556, -0.03190168738365173, 0.010328483767807484, -0.04391271620988846, -0.050876110792160034, -0.03471703082323074, -0.024305254220962524, 0.008362740278244019, 0...
7,370
uuid
__init__
Create a UUID from either a string of 32 hexadecimal digits, a string of 16 bytes as the 'bytes' argument, a string of 16 bytes in little-endian order as the 'bytes_le' argument, a tuple of six integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version, 8-bit clock_seq_hi_variant...
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=SafeUUID.unknown): r"""Create a UUID from either a string of 32 hexadecimal digits, a string of 16 bytes as the 'bytes' argument, a string of 16 bytes in little-endia...
(self, hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=<SafeUUID.unknown: None>)
[ 0.04859641566872597, -0.012406065128743649, 0.006465132348239422, 0.04674629867076874, 0.012868594378232956, -0.048020824790000916, 0.01972430758178234, 0.07149675488471985, -0.0625750795006752, -0.03192480280995369, 0.03655009716749191, 0.10048192739486694, 0.019796255975961685, 0.0463762...
7,371
uuid
__int__
null
def __int__(self): return self.int
(self)
[ -0.016847554594278336, -0.026263320818543434, 0.0329795740544796, 0.04582664743065834, 0.037272773683071136, -0.03554898872971535, 0.016701195389032364, 0.03951694816350937, -0.013131660409271717, -0.0747406929731369, -0.033955302089452744, -0.01505059003829956, 0.018034689128398895, 0.016...
7,372
uuid
__le__
null
def __le__(self, other): if isinstance(other, UUID): return self.int <= other.int return NotImplemented
(self, other)
[ -0.015348751097917557, -0.026149094104766846, -0.02884066104888916, 0.05822645127773285, 0.0021932872477918863, -0.039317332208156586, 0.016575288027524948, 0.02238430455327034, -0.023781195282936096, -0.06102022901177406, 0.03485410287976265, 0.0011147435288876295, 0.039862461388111115, 0...
7,373
uuid
__lt__
null
def __lt__(self, other): if isinstance(other, UUID): return self.int < other.int return NotImplemented
(self, other)
[ -0.018249500542879105, -0.02516995742917061, -0.017241336405277252, 0.03439723327755928, 0.019838642328977585, -0.021923324093222618, 0.04169361665844917, 0.01853998936712742, -0.016865409910678864, -0.0662996843457222, 0.022367600351572037, -0.023256152868270874, 0.01806153729557991, 0.03...
7,374
uuid
__repr__
null
def __repr__(self): return '%s(%r)' % (self.__class__.__name__, str(self))
(self)
[ 0.00522691011428833, -0.03555351123213768, 0.062021322548389435, 0.022380996495485306, 0.01277786586433649, -0.07682505249977112, 0.007151921279728413, 0.007371170911937952, 0.06780950725078583, -0.03823712468147278, -0.03651820868253708, 0.008721748366951942, 0.0008002609829418361, 0.0626...
7,375
uuid
__setattr__
null
def __setattr__(self, name, value): raise TypeError('UUID objects are immutable')
(self, name, value)
[ 0.02759065106511116, -0.010169736109673977, -0.0015712941531091928, 0.016311040148139, -0.013852874748408794, 0.006782564800232649, 0.012118182145059109, 0.04258628562092781, 0.019172050058841705, -0.029070483520627022, -0.004973880480974913, 0.042783595621585846, 0.058140967041254044, 0.0...
7,376
uuid
__setstate__
null
def __setstate__(self, state): object.__setattr__(self, 'int', state['int']) # is_safe was added in 3.7; it is also omitted when it is "unknown" object.__setattr__(self, 'is_safe', SafeUUID(state['is_safe']) if 'is_safe' in state else SafeUUID.unknown)
(self, state)
[ -0.012914884835481644, 0.001934573519974947, 0.02774439938366413, 0.029659029096364975, 0.02090137079358101, -0.017993971705436707, -0.0005717296153306961, 0.022833729162812233, -0.013801286928355694, -0.06733113527297974, -0.026804812252521515, 0.0915476530790329, 0.008447416126728058, 0....
7,377
uuid
__str__
null
def __str__(self): hex = '%032x' % self.int return '%s-%s-%s-%s-%s' % ( hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
(self)
[ -0.02254248782992363, 0.019448082894086838, 0.01631045900285244, 0.0024310103617608547, 0.05210357531905174, -0.0713614970445633, 0.005285556428134441, 0.01377788558602333, 0.04052115976810455, -0.0814572125673294, -0.023873601108789444, 0.04805837199091911, 0.023199401795864105, 0.0123344...
7,378
uuid
_arp_getnode
Get the hardware address on Unix by running arp.
def _arp_getnode(): """Get the hardware address on Unix by running arp.""" import os, socket try: ip_addr = socket.gethostbyname(socket.gethostname()) except OSError: return None # Try getting the MAC addr from arp based on our IP address (Solaris). mac = _find_mac_near_keyword(...
()
[ 0.0413663275539875, -0.003234513569623232, -0.0065354895778000355, -0.011759450659155846, 0.015073719434440136, -0.03211473301053047, -0.003072788007557392, -0.006300655193626881, -0.012060747481882572, -0.08301623165607452, -0.004080804064869881, 0.02752438187599182, 0.004043141845613718, ...
7,379
uuid
_find_mac_near_keyword
Searches a command's output for a MAC address near a keyword. Each line of words in the output is case-insensitively searched for any of the given keywords. Upon a match, get_word_index is invoked to pick a word from the line, given the index of the match. For example, lambda i: 0 would get the first...
def _find_mac_near_keyword(command, args, keywords, get_word_index): """Searches a command's output for a MAC address near a keyword. Each line of words in the output is case-insensitively searched for any of the given keywords. Upon a match, get_word_index is invoked to pick a word from the line, giv...
(command, args, keywords, get_word_index)
[ 0.04213569685816765, 0.014913196675479412, -0.06274832040071487, -0.011417062021791935, -0.015450363047420979, -0.04708855226635933, 0.00484815426170826, 0.011052881367504597, 0.028114743530750275, -0.05291544273495674, -0.01891918294131756, 0.031829386949539185, -0.04242704063653946, -0.0...