Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from MichaelKim0407/dev-v0.3
Browse files Browse the repository at this point in the history
Dev v0.3
  • Loading branch information
MichaelKim0407 authored Nov 14, 2017
2 parents 69d6a74 + 9ff3ecf commit ad32b16
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2
0.3
50 changes: 25 additions & 25 deletions mklsgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

try:
import pty
import termios
except ImportError:
TTY = False
PTY = False
else:
TTY = True
PTY = True

from mklibpy.common.string import AnyString
from mklibpy.terminal.colored_text import get_text, remove_switch
Expand All @@ -24,7 +23,7 @@ def system_call(*args, **kwargs):
return out.decode().splitlines(False)


if TTY:
if PTY:
def system_call_pty(*args, **kwargs):
"""
Opens a pty for stdout, so that colored output is retained.
Expand Down Expand Up @@ -57,10 +56,9 @@ def is_git_repo(abspath):
def get_git_branch(abspath):
with CD(abspath):
for line in system_call(['git', 'branch']):
sp = line.split()
if "*" not in sp:
if not line.startswith("*"):
continue
return sp[1]
return line.lstrip("*").strip()


class LsGit(object):
Expand All @@ -69,19 +67,9 @@ def __init__(self, stdout=None):
if stdout is None:
self.stdout = sys.stdout

if TTY:
@property
def is_tty(self):
try:
termios.tcgetattr(self.stdout)
except termios.error:
return False
else:
return True
else:
@property
def is_tty(self):
return False
@property
def is_tty(self):
return self.stdout.isatty()

@property
def is_gnu(self):
Expand Down Expand Up @@ -113,9 +101,21 @@ def __init__(self, parent, args):
self.__parse_args()

def __parse_args(self):
self.__flags = AnyString([arg for arg in self.__args if arg.startswith('-') and not arg.startswith('--')])
self.__options = AnyString([arg for arg in self.__args if arg.startswith('--')])
self.__dirs = [arg for arg in self.__args if not arg.startswith('-')]
self.__flags = AnyString([
arg
for arg in self.__args
if arg.startswith('-') and not arg.startswith('--')
])
self.__options = AnyString([
arg
for arg in self.__args
if arg.startswith('--')
])
self.__dirs = [
arg
for arg in self.__args
if not arg.startswith('-')
]

@property
def _l(self):
Expand Down Expand Up @@ -169,7 +169,7 @@ def __native_call(self):
def __system_call(self):
return system_call(self.__cmd)

if TTY:
if PTY:
def __system_call_pty(self):
return system_call_pty(self.__cmd)

Expand All @@ -183,7 +183,7 @@ def run(self):
else:
self.__cur_dir = os.getcwd()

if not TTY:
if not PTY:
# See Issue #3
lines = self.__system_call()
workaround_flag = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from setuptools import setup, find_packages
from setuptools import setup

root_dir = os.path.abspath(os.path.dirname(__file__))

Expand Down

0 comments on commit ad32b16

Please sign in to comment.