Skip to content

Commit

Permalink
Improve __repr__ for Command and processes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 4, 2015
1 parent 895de60 commit 7177894
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion chess/uci.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __repr__(self):
if self._result is None:
return "<Command at {0} (finished)>".format(hex(id(self)))
else:
return "<Command at {0} (result {1})>".format(hex(id(self)), self._result)
return "<Command at {0} (result={1})>".format(hex(id(self)), self._result)
else:
return "<Command at {0} (pending)>".format(hex(id(self)))

Expand Down Expand Up @@ -595,6 +595,12 @@ def wait_for_return_code(self):
self._is_dead.wait()
return 0

def pid(self):
return None

def __repr__(self):
return "<MockProcess at {0}>".format(hex(id(self)))


class PopenProcess(object):
def __init__(self, engine, command):
Expand Down Expand Up @@ -637,6 +643,12 @@ def wait_for_return_code(self):
self.process.wait()
return self.process.returncode

def pid(self):
return self.process.pid

def __repr__(self):
return "<PopenProcess at {0} (pid={1})>".format(hex(id(self)), self.pid())


class SpurProcess(object):
def __init__(self, engine, shell, command):
Expand Down Expand Up @@ -685,6 +697,12 @@ def send_line(self, string):
def wait_for_return_code(self):
return self.process.wait_for_result().return_code

def pid(self):
return self.process.pid

def __repr__(self):
return "<SpurProcess at {0} (pid={1})>".format(hex(id(self)), self.pid())


class Engine(object):
def __init__(self, process_cls, args):
Expand Down

0 comments on commit 7177894

Please sign in to comment.