예제 #1
0
def branch_name_from_config_file(directory, config_file):
	try:
		with open(config_file, 'rb') as f:
			raw = f.read()
		return raw.decode(get_preferred_file_contents_encoding(), 'replace').strip()
	except Exception:
		return 'default'
예제 #2
0
def branch_name_from_config_file(directory, config_file):
    try:
        with open(config_file, 'rb') as f:
            raw = f.read()
        return raw.decode(get_preferred_file_contents_encoding(),
                          'replace').strip()
    except Exception:
        return 'default'
예제 #3
0
파일: git.py 프로젝트: ZyX-I/powerline
def branch_name_from_config_file(directory, config_file):
    try:
        with open(config_file, "rb") as f:
            raw = f.read()
    except EnvironmentError:
        return os.path.basename(directory)
    m = _ref_pat.match(raw)
    if m is not None:
        return m.group(1).decode(get_preferred_file_contents_encoding(), "replace")
    return raw[:7]
예제 #4
0
def branch_name_from_config_file(directory, config_file):
	try:
		with open(config_file, 'rb') as f:
			raw = f.read()
	except EnvironmentError:
		return os.path.basename(directory)
	m = _ref_pat.match(raw)
	if m is not None:
		return m.group(1).decode(get_preferred_file_contents_encoding(), 'replace')
	return raw[:7]
예제 #5
0
def branch_name_from_config_file(directory, config_file):
	ans = None
	try:
		with open(config_file, 'rb') as f:
			for line in f:
				m = nick_pat.match(line)
				if m is not None:
					ans = m.group(1).strip().decode(get_preferred_file_contents_encoding(), 'replace')
					break
	except Exception:
		pass
	return ans or os.path.basename(directory)
예제 #6
0
파일: bzr.py 프로젝트: TobiasHoll/powerline
def branch_name_from_config_file(directory, config_file):
    ans = None
    try:
        with open(config_file, 'rb') as f:
            for line in f:
                m = nick_pat.match(line)
                if m is not None:
                    ans = m.group(1).strip().decode(
                        get_preferred_file_contents_encoding(), 'replace')
                    break
    except Exception:
        pass
    return ans or os.path.basename(directory)
예제 #7
0
파일: bzr.py 프로젝트: TobiasHoll/powerline
 def write(self, arg):
     if isinstance(arg, bytes):
         arg = arg.decode(get_preferred_file_contents_encoding(), 'replace')
     return super(CoerceIO, self).write(arg)
예제 #8
0
	def write(self, arg):
		if isinstance(arg, bytes):
			arg = arg.decode(get_preferred_file_contents_encoding(), 'replace')
		return super(CoerceIO, self).write(arg)