bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def main(): gen = None # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A l...
def main(): gen = None # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A l...
35,200
def altlang(code): if code in ['fa','ku']: return ['ar'] if code=='sk': return ['cs'] if code=='nds': return ['de','nl'] if code in ['ca','gn','nah']: return ['es'] if code=='eu': return ['es','fr'] if code=='gl': return ['es','pt'] if code in ['br','oc','th','vi','wa']: return ['fr'] if code=='als': return ['fr','de']...
def altlang(code): if code in ['fa','ku']: return ['ar'] if code=='sk': return ['cs'] if code=='nds': return ['de','nl'] if code in ['ca','gn','nah']: return ['es'] if code=='eu': return ['es','fr'] if code=='gl': return ['es','pt'] if code in ['br','oc','th','vi','wa']: return ['fr'] if code=='als': return ['fr','de']...
35,201
def translate(code, dict): """ Given a language code and a dictionary, returns the dictionary's value for key 'code' if this key exists; otherwise tries to return a value for an alternative language that is most applicable to use on the Wikipedia in language 'code'. The language itself is always checked first, then lan...
def translate(code, dict): """ Given a language code and a dictionary, returns the dictionary's value for key 'code' if this key exists; otherwise tries to return a value for an alternative language that is most applicable to use on the Wikipedia in language 'code'. The language itself is always checked first, then lan...
35,202
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub...
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub...
35,203
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub...
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub...
35,204
def code2encoding(code): if code in ['meta','bs','ru','eo','ja','zh','hi','he','hu','pl','ko','cs','el','sl']: return 'utf-8' return 'iso-8859-1'
def code2encoding(code): if code in ['meta','bs','ru','eo','ja','zh','hi','he','hu','pl','ko','cs','el','sl','ro']: return 'utf-8' return 'iso-8859-1'
35,205
def addEntity(name): """Convert a unicode name into ascii name with entities""" import htmlentitydefs result='' for c in name: if ord(c)<128: result+=str(c) else: for k,v in htmlentitydefs.entitydefs.iteritems(): if (len(v)==1 and ord(c)==ord(v)) or v=='&#%d;'%ord(c): result+='&%s;'%k; break else: raise ValueError("Can...
def addEntity(name): """Convert a unicode name into ascii name with entities""" import htmlentitydefs result='' for c in name: if ord(c)<128: result+=str(c) else: for k,v in htmlentitydefs.entitydefs.iteritems(): if (len(v)==1 and ord(c)==ord(v)) or v=='&#%d;'%ord(c): result+='&%s;'%k; break else: raise NoSuchEntity("C...
35,206
def imagelinks(self): result = [] if self._code in image: im=image[self._code] + ':' else: im='Image:' w1=r'('+im+'[^\]\|]*)' w2=r'([^\]\|]*)' Rlink = re.compile(r'\[\['+w1+r'(\|'+w2+r')?\]\]') for l in Rlink.findall(self.get()): result.append(PageLink(self._code,l[0])) return result
def imagelinks(self): result = [] if self._code in image: im=image[self._code] + ':' else: im='Image:' w1=r'('+im+'[^\]\|]*)' w2=r'([^\]]*)' Rlink = re.compile(r'\[\['+w1+r'(\|'+w2+r')?\]\]') for l in Rlink.findall(self.get()): result.append(PageLink(self._code,l[0])) return result
35,207
def read_pages_from_sql_dump(sqlfilename, old, regex): import sqldump dump = sqldump.SQLdump(sqlfilename, wikipedia.myencoding()) for entry in dump.entries(): if regex: if old.search(entry.text): yield wikipedia.PageLink(wikipedia.mylang, entry.full_title()) else: if entry.text.find(old) != -1: yield wikipedia.PageLink...
def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): import sqldump dump = sqldump.SQLdump(sqlfilename, wikipedia.myencoding()) for entry in dump.entries(): if regex: if old.search(entry.text): yield wikipedia.PageLink(wikipedia.mylang, entry.full_title()) else: if entry.text.find(old) != -1: yie...
35,208
def read_pages_from_sql_dump(sqlfilename, old, regex): import sqldump dump = sqldump.SQLdump(sqlfilename, wikipedia.myencoding()) for entry in dump.entries(): if regex: if old.search(entry.text): yield wikipedia.PageLink(wikipedia.mylang, entry.full_title()) else: if entry.text.find(old) != -1: yield wikipedia.PageLink...
def read_pages_from_sql_dump(sqlfilename, old, regex): import sqldump dump = sqldump.SQLdump(sqlfilename, wikipedia.myencoding()) for entry in dump.entries(): for exception in exceptions: if regex: exception = re.compile(exception) if exception.search(entry.text): break else: if entry.text.find(exception) != -1: break ...
35,209
def read_pages_from_text_file(textfilename, old, regex): f = open(textfilename, 'r') # regular expression which will find [[wiki links]] R = re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for line in f.readlines(): m=R.match(line) if m: yield wikipedia.PageLink(wikipedia.mylang, m.group(1)) f.close()
def read_pages_from_text_file(textfilename): f = open(textfilename, 'r') # regular expression which will find [[wiki links]] R = re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for line in f.readlines(): m=R.match(line) if m: yield wikipedia.PageLink(wikipedia.mylang, m.group(1)) f.close()
35,210
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,211
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,212
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename): yield pl
35,213
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,214
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,215
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,216
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,217
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
def generator(source, old, regex, textfilename = None, sqlfilename = None): if source == 'sqldump': for pl in read_pages_from_sql_dump(sqlfilename, old, regex): yield pl elif source == 'textfile': for pl in read_pages_from_text_file(textfilename, old, regex): yield pl
35,218
def exclusion_file_list(): for i in pages_for_exclusion_database: path = 'copyright/' + i[0] + '/' + i[2] mediawiki_messages.makepath(path) p = wikipedia.Page(wikipedia.getSite(i[0]),i[1]) yield p, path
def exclusion_file_list(): for i in pages_for_exclusion_database: path = appdir + i[0] + '/' + i[2] mediawiki_messages.makepath(path) p = wikipedia.Page(wikipedia.getSite(i[0]),i[1]) yield p, path
35,219
def load_pages(): write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()) f.cl...
def load_pages(force_update = False): for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()...
35,220
def load_pages(): write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()) f.cl...
def load_pages(): write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating page [[' + page.title() + ']] to exclude new URLs...' length = 0 except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(p...
35,221
def load_pages(): write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()) f.cl...
def load_pages(): write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: pass if length == 0 or force_update: try: data = page.get() f = codecs.open(path, '...
35,222
def check_list(text, cl): for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text #print 'DEBUG: ' + entry return True
def check_list(text, cl, debug=False): for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text #print 'DEBUG: ' + entry return True
35,223
def check_list(text, cl): for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text #print 'DEBUG: ' + entry return True
def check_list(text, cl): for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text #print 'DEBUG: ' + entry return True
35,224
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
35,225
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
35,226
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
35,227
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
def exclusion_list(): prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:...
35,228
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = re.sub('(?i)<br(\s*/)?>', '', text) text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$", "", text) text = re.sub('^[:*]?["][^"]+...
35,229
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^[:*]?\s*''.*?''\.?\s*((\(|<ref>...
35,230
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
35,231
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.s...
35,232
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
def cleanwikicode(text): if not text: return "" #wikipedia.output(text) text = text.replace("<br>", "") text = text.replace("<br/>", "") text = text.replace("<br />", "") text = re.sub('<!--.*?-->', '', text) if exclude_quote: text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)...
35,233
def query(lines = [], max_query_len = 1300): # Google max_query_len = 1480? # - '-Wikipedia ""' = 1467 output = u"" n_query = 0 for line in lines: line = cleanwikicode(line) if len(line)>200: n_query+=1 if n_query>max_query_for_page: print "Max query limit for page reached" return output if len(line)>max_query_len: li...
def query(lines = [], max_query_len = 1300): # Google max_query_len = 1480? # - '-Wikipedia ""' = 1467 output = u"" n_query = 0 for line in lines: line = cleanwikicode(line) if len(line)>200: n_query+=1 if n_query>max_query_for_page: print "Max query limit for page reached" return output if len(line)>max_query_len: li...
35,234
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry: #SOAP.faultType: <Fault SOAP-ENV:Server: Exception from service object: # Daily limit of 1000 queries exceeded fo...
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry: #SOAP.faultType: <Fault SOAP-ENV:Server: Exception from service object: # Daily limit of 1000 queries exceeded fo...
35,235
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry: #SOAP.faultType: <Fault SOAP-ENV:Server: Exception from service object: # Daily limit of 1000 queries exceeded fo...
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry: #SOAP.faultType: <Fault SOAP-ENV:Server: Exception from service object: # Daily limit of 1000 queries exceeded fo...
35,236
def run(self): """ Starts the robot. """ # Run the generator which will yield Pages which might need to be # checked. for page in self.generator: try: # Load the page's text from the wiki original_text = page.get() except wikipedia.NoPage: wikipedia.output(u'Page %s not found' % page.title()) continue except wikipedia....
def run(self): """ Starts the robot. """ # Run the generator which will yield Pages which might need to be # checked. for page in self.generator: try: # Load the page's text from the wiki original_text = page.get() except wikipedia.NoPage: wikipedia.output(u'Page %s not found' % page.title()) continue except wikipedia....
35,237
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo, max_query_for_page, output_file gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be u...
35,238
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
35,239
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
35,240
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
35,241
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
35,242
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
def main(): global search_in_google, search_in_yahoo gen = None # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # the textfile's path, either absolute or relative, which will be used when # source is 'textfile'. textfilename = None # the category name which will be used when source is 'category'. ca...
35,243
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
35,244
def output(text, decoder = None, newline=True): if decoder: text = unicode(text, decoder) if newline: print text.encode(config.console_encoding, 'replace') else: # comma means 'don't print newline after question' print text.encode(config.console_encoding, 'replace'),
def output(text, decoder = None, newline = True): if decoder: text = unicode(text, decoder) if newline: print text.encode(config.console_encoding, 'replace') else: # comma means 'don't print newline after question' print text.encode(config.console_encoding, 'replace'),
35,245
def get_image(fn,target,description): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The fi...
def get_image(fn, target, description, debug=False): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1...
35,246
def get_image(fn,target,description): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The fi...
def get_image(fn,target,description): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The fi...
35,247
def get_image(fn,target,description): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The fi...
def get_image(fn,target,description): uploadaddr='/wiki/%s:Upload'%wikipedia.special[wikipedia.mylang] # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The fi...
35,248
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
35,249
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
35,250
def cleanUpLinks(self, text): trailR = re.compile(self.site.linktrail()) # The regular expression which finds links. Results consist of four groups: # group title is the target page title, that is, everything before | or ]. # group section is the page section. It'll include the # to make life easier for us. # group lab...
def cleanUpLinks(self, text): trailR = re.compile(self.site.linktrail()) # The regular expression which finds links. Results consist of four groups: # group title is the target page title, that is, everything before | or ]. # group section is the page section. It'll include the # to make life easier for us. # group lab...
35,251
def isInterwikiLink(self, s): """ Try to check whether s is in the form "foo:bar" where foo is a known language code or family. In such a case we are dealing with an interwiki link. """ if not ':' in s: return False first, rest = s.split(':',1) # interwiki codes are case-insensitive first = first.lower() if first in se...
def isInterwikiLink(self, s): """ Try to check whether s is in the form "foo:bar" where foo is a known language code or family. In such a case we are dealing with an interwiki link. """ if not ':' in s: return False first, rest = s.split(':',1) # interwiki codes are case-insensitive first = first.lower() if first in se...
35,252
def validLanguageLinks(self): langlist = [] for language in self.languages(): if not language in self.namespaces(): langlist += [language] return langlist
def validLanguageLinks(self): langlist = [] for language in self.languages(): if not language[0].upper()+language[1:] in self.namespaces(): langlist += [language] return langlist
35,253
def add_category(): print "This bot has two modes: you can add a category link to all" print "pages mentioned in a List that is now in another wikipedia page" print "or you can add a category link to all pages that link to a" print "specific page. If you want the second, please give an empty" print "answer to the first...
def add_category(): print "This bot has two modes: you can add a category link to all" print "pages mentioned in a List that is now in another wikipedia page" print "or you can add a category link to all pages that link to a" print "specific page. If you want the second, please give an empty" print "answer to the first...
35,254
def remove_category(): old_title = wikipedia.input('Please enter the name of the category that should be removed: ') old_cat = catlib.CatLink(old_title) # get edit summary message wikipedia.setAction(msg_delete[wikipedia.chooselang(wikipedia.mylang,msg_delete)] % old_title) articles = old_cat.articles(recurse = 0) if ...
def remove_category(): old_title = wikipedia.input('Please enter the name of the category that should be removed: ') old_cat = catlib.CatLink(old_title) # get edit summary message wikipedia.setAction(msg_delete[wikipedia.chooselang(wikipedia.mylang,msg_delete)] % old_title) articles = old_cat.articles(recurse = 0) if ...
35,255
def __init__(self, site, title = None, insite = None, tosite = None): """ Constructor. Normally called with two arguments: Parameters: 1) The wikimedia site on which the page resides 2) The title of the page as a unicode string The argument insite can be specified to help decode the name; it is the wikimedia site wher...
def __init__(self, site, title = None, insite = None, tosite = None): """ Constructor. Normally called with two arguments: Parameters: 1) The wikimedia site on which the page resides 2) The title of the page as a unicode string The argument insite can be specified to help decode the name; it is the wikimedia site wher...
35,256
def dump(self, filename = 'category.dump.bz2'): ''' Saves the contents of the dictionaries superclassDB and catContentDB to disk. ''' wikipedia.output(u'Dumping to %s, please wait...' % filename) f = bz2.BZ2File(filename, 'w') databases = { 'catContentDB': self.catContentDB, 'superclassDB': self.superclassDB } # store ...
def dump(self, filename = 'category.dump.bz2'): ''' Saves the contents of the dictionaries superclassDB and catContentDB to disk. ''' wikipedia.output(u'Dumping to %s, please wait...' % filename) f = bz2.BZ2File(filename, 'w') databases = { 'catContentDB': self.catContentDB, 'superclassDB': self.superclassDB } # store ...
35,257
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
35,258
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
35,259
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
def __init__(self, code, name = None, urlname = None, linkname = None, incode = None): """Constructor. Normally called with two arguments: 1) The language code on which the page resides 2) The name of the page as suitable for a URL """ self._incode = incode self._code = code if linkname is None and urlname is None and ...
35,260
def output(self, text, colors = None, newline = True): """ If a character can't be displayed in the encoding used by the user's terminal, it will be replaced with a question mark or by a transliteration.
def output(self, text, colors = None, newline = True): """ If a character can't be displayed in the encoding used by the user's terminal, it will be replaced with a question mark or by a transliteration.
35,261
def get(self, read_only = False, force = False, get_redirect=False, throttle = True): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
def get(self, read_only = False, force = False, get_redirect=False, throttle = True): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
35,262
def category_on_one_line(self): return self.lang in site.family.category_on_one_line
def category_on_one_line(self): return self.lang in site.family.category_on_one_line
35,263
def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ...
def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ...
35,264
def findpage(t): try: location = re.search(starttext+"([^\Z]*?)"+endtext,t) if include: page = location.group() else: page = location.group(1) except AttributeError: return try: title = re.search("'''(.*?)'''",page).group(1) pl = wikipedia.PageLink(mysite,title) if pl.exists(): print "Page %s already exists, not adding...
def findpage(t): try: location = re.search(starttext+"([^\Z]*?)"+endtext,t) if include: page = location.group() else: page = location.group(1) except AttributeError: return try: title = re.search("'''(.*?)'''",page).group(1) pl = wikipedia.PageLink(mysite,title) if pl.exists(): print "Page %s already exists, not adding...
35,265
def findpage(t): try: location = re.search(starttext+"([^\Z]*?)"+endtext,t) if include: page = location.group() else: page = location.group(1) except AttributeError: return try: title = re.search("'''(.*?)'''",page).group(1) pl = wikipedia.PageLink(mysite,title) if pl.exists(): print "Page %s already exists, not adding...
def findpage(t): try: location = re.search(starttext+"([^\Z]*?)"+endtext,t) if include: page = location.group() else: page = location.group(1) except AttributeError: return try: title = re.search("'''(.*?)'''",page).group(1) pl = wikipedia.PageLink(mysite,title) if pl.exists(): print "Page %s already exists, not adding...
35,266
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
35,267
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False xmlfilename = None text...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False xmlfilename = None text...
35,268
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False xmlfilename = None text...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False xmlfilename = None text...
35,269
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
35,270
def main(): start = '!' sqlfilename = None for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, logname = 'weblinkchecker.log') if arg: if arg.startswith('-sql'): if len(arg) == 4: sqlfilename = wikipedia.input(u'Please enter the SQL dump\'s filename: ') else: sqlfilename = arg[5:] source = sqlfilename elif arg.sta...
def main(): start = '!' sqlfilename = None for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, logname = 'weblinkchecker.log') if arg: if arg.startswith('-sql'): if len(arg) == 4: sqlfilename = wikipedia.input(u'Please enter the SQL dump\'s filename: ') else: sqlfilename = arg[5:] source = sqlfilename elif arg.sta...
35,271
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,272
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,273
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,274
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,275
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,276
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,277
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,278
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,279
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,280
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,281
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,282
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted tabl...
35,283
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,284
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,285
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,286
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,287
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,288
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
35,289
def main(): if __name__ == "__main__": action = None sort_by_last_name = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg) if arg: if arg == 'add': action = 'add' elif arg == 'remove': action = 'remove' elif arg == 'rename': action = 'rename' elif arg == 'tidy': action = 'tidy' elif arg == 'tree': action =...
if __name__ == "__main__": try: action = None sort_by_last_name = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg) if arg: if arg == 'add': action = 'add' elif arg == 'remove': action = 'remove' elif arg == 'rename': action = 'rename' elif arg == 'tidy': action = 'tidy' elif arg == 'tree': action = 'tree'...
35,290
def main(): if __name__ == "__main__": action = None sort_by_last_name = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg) if arg: if arg == 'add': action = 'add' elif arg == 'remove': action = 'remove' elif arg == 'rename': action = 'rename' elif arg == 'tidy': action = 'tidy' elif arg == 'tree': action =...
def main(): if __name__ == "__main__": action = None sort_by_last_name = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg) if arg: if arg == 'add': action = 'add' elif arg == 'remove': action = 'remove' elif arg == 'rename': action = 'rename' elif arg == 'tidy': action = 'tidy' elif arg == 'tree': action =...
35,291
def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ # Get file contents if '://' in self...
def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ # Get file contents if '://' in self...
35,292
def run(self): dt=15 while True: try: data = self.getData() except (socket.error, httplib.BadStatusLine, ServerError): # Print the traceback of the caught exception print ''.join(traceback.format_exception(*sys.exc_info())) output(u'DBG> got network error in GetAll.run. Sleeping for %d seconds'%dt) time.sleep(dt) if dt...
def run(self): dt=15 while True: try: data = self.getData() except (socket.error, httplib.BadStatusLine, ServerError): # Print the traceback of the caught exception print ''.join(traceback.format_exception(*sys.exc_info())) output(u'DBG> got network error in GetAll.run. Sleeping for %d seconds'%dt) time.sleep(dt) if dt...
35,293
def get(self, read_only = False): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
def get(self, read_only = False): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
35,294
def putPage(self, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, token = None, gettoken = False, sysop = False): """ Upload 'text' as new contents for this Page by filling out the edit page.
def putPage(self, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, token = None, gettoken = False, sysop = False): """ Upload 'text' as new contents for this Page by filling out the edit page.
35,295
def dh_simpleInt( value ): """decoding helper for a single integer value representing a year with no extra symbols""" return dh_noConv( value, u'%d' )
def dh_simpleInt( value ): """decoding helper for a single integer value representing a year with no extra symbols""" return dh_noConvYear( value, u'%d' )
35,296
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
35,297
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
35,298
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
35,299