diff options
author | Jon Bernard <jbernard@tuxion.com> | 2015-12-31 11:21:57 -0500 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2015-12-31 11:25:04 -0500 |
commit | ee9279c23cf2b734f4cfde558e909ca4acefa421 (patch) | |
tree | e34aac88e4ab904d01c04c4eaa5546e6e82d36d9 | |
parent | daf76e747a0dbc9749e3d3007e26e7280fee7868 (diff) | |
download | dotfiles-ee9279c23cf2b734f4cfde558e909ca4acefa421.tar.gz dotfiles-ee9279c23cf2b734f4cfde558e909ca4acefa421.tar.bz2 dotfiles-ee9279c23cf2b734f4cfde558e909ca4acefa421.zip |
Update dotfile __repr__ and initialize state
-rw-r--r-- | dotfiles/dotfile.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/dotfiles/dotfile.py b/dotfiles/dotfile.py index 14a8d53..0b15dbd 100644 --- a/dotfiles/dotfile.py +++ b/dotfiles/dotfile.py @@ -26,24 +26,19 @@ class Dotfile(object): def __init__(self, name, target): self.name = name self.target = target - - def __repr__(self): - return repr((str(self.name), str(self.target), self.state())) + self.state = '(unknown)' def __str__(self): short_name, short_target = self._truncate_paths() - return '{} -> {} {}'.format(short_name, short_target, self.state()) + return '%s -> %s %s' % (short_name, short_target, self.state) + + def __repr__(self): + return '<Dotfile %r>' % self.name def _truncate_paths(self): discard = len(str(self.name.common(self.target))) + 1 return (str(self.name)[discard:], str(self.target)[discard:]) - def state(self): - return '(unknown)' - - def invalid(self): - return self.state() != '(ok)' - def add(self): if self.target.check(exists=1): raise OSError(errno.EEXIST, self.target) @@ -58,3 +53,6 @@ class Dotfile(object): def sync(self): self.name.mksymlinkto(self.target) + + def invalid(self): + return self.state != '(ok)' |