Skip to content

Commit

Permalink
fallback to top-level CITATION.cff
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlancaster committed Nov 14, 2024
1 parent 5eb5559 commit ecec313
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/PyPop/CommandLineInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ def __call__(self, parser, namespace, values, option_string=None):
from importlib_resources import files
citation_file = files('PyPop').joinpath(citation_file_name)
citation_text = citation_file.read_text()
except (ModuleNotFoundError, ImportError, FileNotFoundError): # fallback to looking in current directory if running from repo
pypop_dir = Path(__file__).resolve().parent
citation_file = pypop_dir / citation_file_name
except (ModuleNotFoundError, ImportError, FileNotFoundError): # fallback to looking in top-level directory if running from repo
top_level_dir = Path(__file__).resolve().parent.parent.parent
citation_file = top_level_dir / 'CITATION.cff' # only output CFF

if citation_file.exists():
print("only CITATION.cff is available")
print()
citation_text = citation_file.read_text()
else:
print("could not locate the specified citation format.")
parser.exit()

print(citation_text)
parser.exit() # exit after printing the file

Expand Down

0 comments on commit ecec313

Please sign in to comment.