def load_users():
  try:
    with open(app.config['USERS_FILE'], 'r') as user_data_file:
      users = User.from_yaml(user_data_file.read())
    logging.info("Loaded %s users from %s" % (len(users),
                                              app.config['USERS_FILE']))
  except IOError:
    logging.warning("Could not open %s to read users" %
                    app.config['USERS_FILE'])
    users = {}
  except Exception as e:
    logging.error("There was a problem parsing users from %s" %
                      app.config['USERS_FILE'], exc_info=e)
    users = {}

  publication_users = publications.get_users()
  publication_users.update(users)
  users = publication_users

  def by_name(user_id__user):
    user_id, user = user_id__user
    return user.ordered_name()
  users = OrderedDict(sorted(users.items(), key=by_name))

  logging.info("Merge users from userfile with users from publications, %s found" % len(users))

  return users
def load_users():
    try:
        with open(app.config['USERS_FILE'], 'r') as user_data_file:
            users = User.from_yaml(user_data_file.read())
        logging.info("Loaded %s users from %s" %
                     (len(users), app.config['USERS_FILE']))
    except IOError:
        logging.warning("Could not open %s to read users" %
                        app.config['USERS_FILE'])
        users = {}
    except Exception as e:
        logging.error("There was a problem parsing users from %s" %
                      app.config['USERS_FILE'],
                      exc_info=e)
        users = {}

    publication_users = publications.get_users()
    publication_users.update(users)
    users = publication_users

    def by_name(user_id__user):
        user_id, user = user_id__user
        return user.ordered_name()

    users = OrderedDict(sorted(users.items(), key=by_name))

    logging.info(
        "Merge users from userfile with users from publications, %s found" %
        len(users))

    return users
  (options, args)=main()
  check_command_line()

  try:
    with open(options.publicationsfile, 'r') as publications_input:
      publications = Publications.from_yaml(publications_input.read())
  except IOError:
    # The file is missing
    logging.info("Could not load existing publications from %s, skipping" %
                options.publicationsfile)
    publications={}
  users={}

  with open(options.usersfile, "r") as usersfile:
    users = User.from_yaml(usersfile.read())
  users_count = len(users)
  logging.info("Loaded %s users from %s" % (users_count, options.usersfile))

  pubmed_ids = set()
  logging.info("Searching pubmed for publications")
  for user in users.values():
    new_pubmed_ids = Searcher.get_pubmed_ids_for_user(user, options.start, options.end)
    pubmed_ids.update(new_pubmed_ids)
  pubmed_id_count = len(pubmed_ids)
  logging.info("Found %s citations by searching pubmed" % pubmed_id_count)

  logging.info("Getting pubmed_ids from the Library")
  new_pubmed_ids = LibrarySearcher.get_pubmed_ids(options.start, options.end)
  pubmed_ids.update(new_pubmed_ids)
  logging.info("Found additional %s publications in Library" % (len(pubmed_ids) - pubmed_id_count))
Example #4
0
    (options, args) = main()
    check_command_line()

    try:
        with open(options.publicationsfile, 'r') as publications_input:
            publications = Publications.from_yaml(publications_input.read())
    except IOError:
        # The file is missing
        logging.info("Could not load existing publications from %s, skipping" %
                     options.publicationsfile)
        publications = {}
    users = {}

    with open(options.usersfile, "r") as usersfile:
        users = User.from_yaml(usersfile.read())
    users_count = len(users)
    logging.info("Loaded %s users from %s" % (users_count, options.usersfile))

    pubmed_ids = set()
    logging.info("Searching pubmed for publications")
    for user in users.values():
        new_pubmed_ids = Searcher.get_pubmed_ids_for_user(
            user, options.start, options.end)
        pubmed_ids.update(new_pubmed_ids)
    pubmed_id_count = len(pubmed_ids)
    logging.info("Found %s citations by searching pubmed" % pubmed_id_count)

    logging.info("Getting pubmed_ids from the Library")
    new_pubmed_ids = LibrarySearcher.get_pubmed_ids(options.start, options.end)
    pubmed_ids.update(new_pubmed_ids)