b-ryan.powerline-shell/powerline_shell/segments/svn.py
Emanuel Angelo 2c0a5909ce Renames some RepoStats class qualifiers to more generic terms
untracked -> new
not_staged -> changed
2017-09-14 00:25:24 +01:00

30 lines
953 B
Python

import subprocess
from ..utils import BasicSegment, RepoStats
class Segment(BasicSegment):
def add_to_powerline(self):
is_svn = subprocess.Popen(["svn", "status"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
is_svn_output = is_svn.communicate()[1].decode("utf-8").strip()
if len(is_svn_output) != 0:
return
try:
p1 = subprocess.Popen(["svn", "status"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError:
return
stdout = p1.communicate()[0]
stats = RepoStats()
for line in stdout.splitlines():
if line[0] == "?":
stats.new += 1
elif line[0] == "C":
stats.conflicted += 1
elif line[0] in ["A", "D", "I", "M", "R", "!", "~"]:
stats.changed += 1
stats.add_to_powerline(self.powerline)