def data_from_repo_or_none(repo): """Returns a valid 'Data' if 'repo' has a config file. Will raise if the config file could not be parsed. Will return 'None' if no config file was found. :repo: a callable supporting git commands, e.g. repo("status") :returns: a valid 'Data' or None """ config = None # try to get the file content from the special ref, if it exists ref = 'refs/config/origin/arcyd' if ref in phlgit_showref.names(repo): try: config = phlgit_show.file_on_ref( repo, 'repo.json', ref) except Exception: pass if config is not None: config = data_from_json(config) return config
def data_from_repo_or_none(repo): """Returns a valid 'Data' if 'repo' has a config file. Will raise if the config file could not be parsed. Will return 'None' if no config file was found. :repo: a git repo object that supports call() :returns: a valid 'Data' or None """ config = None try: config = phlgit_show.file_on_ref( repo, 'repo.json', 'refs/config/origin/arcyd') except Exception: pass if config is not None: config = data_from_json(config) return config