def process_voinfo(scm_generated, found, not_found, description_hashes, key, voinfo, recheck=False): '''Process given plugin If ``recheck`` is ``True`` then it only prints to stderr whether something changed. If ``recheck`` is ``False`` then it records found URL in scm_generated and puts corresponding plugin number into ``found``. If no URL was found it records plugin number into ``not_found``. ''' logger.info( '> Checking plugin {script_name} (vimscript #{script_id})'.format( **voinfo)) try: candidate = find_repo_candidate(voinfo) if recheck: desc = '%s : %s' % (voinfo['script_id'], voinfo['script_name']) if candidate: c_sg = candidate_to_sg(candidate) s_sg = scm_generated[voinfo['script_id']] if c_sg == s_sg: print('== ' + desc) else: logger.info('> {0!r} (new) /= {1!r} (old)'.format( c_sg, s_sg)) print('/= ' + desc) else: print('no ' + desc) else: if candidate: scm_generated[key] = candidate_to_sg(candidate) logger.info('> Recording found candidate for {0}: {1}'.format( key, scm_generated[key])) not_found.discard(key) else: logger.info( '> Recording failure to find candidates for {0}'.format( key)) not_found.add(key) found.add(key) if not args['--no-descriptions']: description_hashes[key] = get_voinfo_hash(voinfo) except Exception as e: logger.exception(e)
def process_voinfo(scm_generated, found, not_found, description_hashes, key, voinfo, recheck=False): '''Process given plugin If ``recheck`` is ``True`` then it only prints to stderr whether something changed. If ``recheck`` is ``False`` then it records found URL in scm_generated and puts corresponding plugin number into ``found``. If no URL was found it records plugin number into ``not_found``. ''' logger.info('> Checking plugin {script_name} (vimscript #{script_id})' .format(**voinfo)) try: candidate = find_repo_candidate(voinfo) if recheck: desc = '%s : %s' % (voinfo['script_id'], voinfo['script_name']) if candidate: c_sg = candidate_to_sg(candidate) s_sg = scm_generated[voinfo['script_id']] if c_sg == s_sg: print ('== ' + desc) else: logger.info('> {0!r} (new) /= {1!r} (old)'.format(c_sg, s_sg)) print ('/= ' + desc) else: print ('no ' + desc) else: if candidate: scm_generated[key] = candidate_to_sg(candidate) logger.info('> Recording found candidate for {0}: {1}' .format(key, scm_generated[key])) not_found.discard(key) else: logger.info('> Recording failure to find candidates for {0}'.format(key)) not_found.add(key) found.add(key) if not args['--no-descriptions']: description_hashes[key] = get_voinfo_hash(voinfo) except Exception as e: logger.exception(e)
def main(): scmnrs = process_scmsources() omitted = load_scmnrs_json(scmnrs, omitted_name) found = scmnrs.copy() scm_generated = load_scmnrs_json(scmnrs, scm_generated_name) not_found = load_scmnrs_json(scmnrs, not_found_name, set) if not args['--no-descriptions']: try: with open(description_hashes_name) as DHF: description_hashes = json.load(DHF) except IOError: description_hashes = {} else: description_hashes = {} if args['scripts']: keys = args['<SID>'] not_found -= set(keys) elif args['last']: i = args['last'] _keys = reversed(sorted(db, key=int)) keys = [] while i: keys.append(next(_keys)) i -= 1 else: keys = reversed(sorted(db, key=int)) _process_voinfo = partial(process_voinfo, scm_generated, found, not_found, description_hashes) with lshg.MercurialRemoteParser() as remote_parser: set_remote_parser(remote_parser) if args['recheck']: for key in scm_generated: _process_voinfo(key, db[key], recheck=True) else: for key in keys: if not args['--force'] and key in scmnrs: if args['new']: break else: continue logger.info('Considering key {0}'.format(key)) _process_voinfo(key, db[key]) if not args['--no-descriptions']: logger.info('Starting descriptions check') for key in keys: voinfo = db[key] changed = False if key not in description_hashes: h = get_voinfo_hash(voinfo) description_hashes[key] = h changed = True if key in found: continue if not changed: h = get_voinfo_hash(voinfo) changed = (h != description_hashes.get(key)) if changed: logger.info( 'Hash for key {0} changed, checking it'.format( key)) description_hashes[key] = h else: logger.info('New hash for key {0}'.format(key)) if changed: _process_voinfo(key, voinfo) return scm_generated, not_found, description_hashes
def main(): scmnrs = process_scmsources() omitted = load_scmnrs_json(scmnrs, omitted_name) found = scmnrs.copy() scm_generated = load_scmnrs_json(scmnrs, scm_generated_name) not_found = load_scmnrs_json(scmnrs, not_found_name, set) if not args['--no-descriptions']: try: with open(description_hashes_name) as DHF: description_hashes = json.load(DHF) except IOError: description_hashes = {} else: description_hashes = {} if args['scripts']: keys = args['<SID>'] not_found -= set(keys) elif args['last']: i = args['last'] _keys = reversed(sorted(db, key=int)) keys = [] while i: keys.append(next(_keys)) i -= 1 else: keys = reversed(sorted(db, key=int)) _process_voinfo = partial(process_voinfo, scm_generated,found,not_found,description_hashes) with lshg.MercurialRemoteParser() as remote_parser: set_remote_parser(remote_parser) if args['recheck']: for key in scm_generated: _process_voinfo(key, db[key], recheck=True) else: for key in keys: if not args['--force'] and key in scmnrs: if args['new']: break else: continue logger.info('Considering key {0}'.format(key)) _process_voinfo(key, db[key]) if not args['--no-descriptions']: logger.info('Starting descriptions check') for key in keys: voinfo = db[key] changed = False if key not in description_hashes: h = get_voinfo_hash(voinfo) description_hashes[key] = h changed = True if key in found: continue if not changed: h = get_voinfo_hash(voinfo) changed = (h != description_hashes.get(key)) if changed: logger.info('Hash for key {0} changed, checking it'.format(key)) description_hashes[key] = h else: logger.info('New hash for key {0}'.format(key)) if changed: _process_voinfo(key, voinfo) return scm_generated, not_found, description_hashes