def convert_dumps(): """Convert interwikidump from pickle format to txt format.""" folder = config.datafilepath('data', 'interwiki-dumps') for old_file, new_file, site in pickle_files(folder): # read old file pywikibot.output('\nReading {}...'.format(old_file)) old_filepath = os.path.join(folder, old_file) titles = read_content(old_filepath) if not titles: pywikibot.error('Unable to read ' + old_file) continue # write new file pywikibot.output('Writing {}...'.format(new_file)) write_content(os.path.join(folder, new_file), site, titles) # delete old file try: os.remove(old_filepath) pywikibot.output('Old dumpfile {} deleted'.format(old_file)) except OSError as e: pywikibot.error( 'Cannot delete {} due to\n{}\nDo it manually.'.format( old_file, e))
def run(self): """Write graphs to the data directory.""" for fmt in config.interwiki_graph_formats: filename = config.datafilepath('interwiki-graphs/' + getFilename(self.origin, fmt)) if self.graph.write(filename, prog='dot', format=fmt): pywikibot.output('Graph saved as ' + filename) else: pywikibot.output('Graph could not be saved as ' + filename)
def run(self): """Write graphs to the data directory.""" for format in config.interwiki_graph_formats: filename = config.datafilepath( 'interwiki-graphs/' + getFilename(self.originPage, format)) if self.graph.write(filename, prog='dot', format=format): pywikibot.output(u'Graph saved as %s' % filename) else: pywikibot.output(u'Graph could not be saved as %s' % filename)
issue_deprecation_warning, file_mode_checker, ) try: import requests_oauthlib except ImportError as e: requests_oauthlib = e # The error message for failed SSL certificate verification # 'certificate verify failed' is a commonly detectable string SSL_CERT_VERIFY_FAILED_MSG = 'certificate verify failed' _logger = 'comms.http' cookie_file_path = config.datafilepath('pywikibot.lwp') file_mode_checker(cookie_file_path, create=True) cookie_jar = cookiejar.LWPCookieJar(cookie_file_path) try: cookie_jar.load(ignore_discard=True) except cookiejar.LoadError: debug('Loading cookies failed.', _logger) else: debug('Loaded cookies from file.', _logger) session = requests.Session() session.cookies = cookie_jar # Prepare flush on quit def _flush():