import git import os from pathlib import Path from enum import Enum from typing import List, Tuple, Optional import pandas as pd from dataclasses import dataclass import os import yaml from dataclasses import dataclass from typing import Dict, Optional, List import pandas as pd import yaml from pyalex import Works import json try: PROJECT_ROOT = Path( git.Repo(Path.cwd(), search_parent_directories=True).working_dir ) except git.exc.InvalidGitRepositoryError: PROJECT_ROOT = Path.cwd() os.environ["PROJECT_ROOT"] = str(PROJECT_ROOT) def get_profile_information() -> Dict[str, str]: """ Get the email and the api_key from the profile file """ # create the path to the profile file profile = f"{PROJECT_ROOT}/user_information/profile.yaml" # check if the profile exists and if you are running inside the correct folder assert str(PROJECT_ROOT).split("/")[-1] == "MatchingPubs", "Please run this script in the github repo folder " assert os.path.exists(profile), "create a profile.yaml with your email (email:) and your api key (api_key:). Go here to get one https://dev.elsevier.com/" # load the profile file with open(profile, "r") as f: profile = yaml.safe_load(f) # access the email and the api_key email = profile["email"] api_key = profile["api_key"].strip() # remove the spaces return {"email": email, "api_key": api_key}