def __init__(self, repodir, name='Main module', parent=None):
        self.name = name
        self.parent = parent

        # Search for .git directory in repodir ancestors
        repodir = os.path.abspath(repodir)
        try:
            if parent:
                if not os.path.isdir(os.path.join(repodir, '.git')):
                    raise GitError, "Not a git repository: %s" % repodir
            else:
                while not os.path.isdir(os.path.join(repodir, '.git')):
                    new_repodir = os.path.abspath(os.path.join(repodir, '..'))
                    if new_repodir == repodir or (parent and new_repodir == parent.dir):
                        raise GitError, "Directory is not a git repository"
                    else:
                        repodir = new_repodir
        except __HOLE__:
            raise GitError, "Directory is not a git repository or it is not readable"
            
        self.dir = repodir

        # Remotes
        self.config = ConfigFile(os.path.join(self.dir, '.git', 'config'))
        self.url = self.config.get_option('remote', 'origin', 'url')

        self.remotes = {}
        for remote, opts in self.config.sections_for_type('remote'):
            if 'url' in opts:
                self.remotes[remote] = opts['url']

        # Run a git status to see whether this is really a git repository
        retcode,output = self.run_cmd(['status'], with_retcode=True)
        if retcode not in [0,1]:
            raise GitError, "Directory is not a git repository"

        # Load refs
        self.load_refs()

        # Get submodule info
        self.submodules = self.get_submodules()
        self.all_modules = [self] + self.submodules
dataset/ETHPy150Open gyim/stupidgit/stupidgit_gui/git.py/Repository.__init__