def cwd_to_view_name(): """Glean the view name from the current working directory's path: it's the 'foo' in 'foo/.git/'. If the Git Fusion RC file is present, then the view name will be read from the file. """ config = p4gf_rc.read_config() view_name = p4gf_rc.get_view(config) if view_name is None: # Fall back to using directory name as view name. path = p4gf_path.cwd_to_dot_git() (path, _git) = os.path.split(path) (path, view_name) = os.path.split(path) return view_name
def test_vars(): """Return a dict of test key/value pairs that the test script controls. Used to let test scripts control internal behavior, such as causing a loop to block until the test script has a chance to introduce a conflict at a known time. Eventually this needs to be read from env or a file or something that the test script controls. Return an empty dict if not testing (the usual case). """ config = p4gf_rc.read_config() if not config: LOG.debug("test_vars no config.") return {} if not config.has_section(p4gf_const.P4GF_TEST): LOG.debug("test_vars config, no [test].") return {} d = {i[0]:i[1] for i in config.items(p4gf_const.P4GF_TEST)} LOG.debug("test_vars returning {}".format(d)) return d
def test_vars(): """Return a dict of test key/value pairs that the test script controls. Used to let test scripts control internal behavior, such as causing a loop to block until the test script has a chance to introduce a conflict at a known time. Eventually this needs to be read from env or a file or something that the test script controls. Return an empty dict if not testing (the usual case). """ config = p4gf_rc.read_config() if not config: LOG.debug("test_vars no config.") return {} if not config.has_section(p4gf_const.P4GF_TEST): LOG.debug("test_vars config, no [test].") return {} d = {i[0]: i[1] for i in config.items(p4gf_const.P4GF_TEST)} LOG.debug("test_vars returning {}".format(d)) return d
def rc_path_to_view_name(rc_path): """Read the rc file at rc_path and return the view name stored within the rc file.""" config = p4gf_rc.read_config(rc_path=rc_path) return p4gf_rc.get_view(config)