Source code for egaia.egaia_root

import os

[docs]def get_root(path=None): """Return the root of the current collection.""" if not path: path = os.getcwd() # Walk upwards, looking for a "bagit.txt" file. This should be created # on initialization of an archive. while not 'bagit.txt' in os.listdir(path): path = os.path.dirname(path) if os.path.basename(path) == '': #print "Could not find collection root in the current path!" return None os.chdir(path) return path
def _cli(args): """egaia root Locate the root of the current collection. The root directory is located by the presence of a "bagit.txt" file, which should be created automatically when the command "egaia bag" is used. Usage: egaia root --help egaia root """ print get_root()