mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
30 lines
953 B
Python
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)
|