diff options
author | Steve Frécinaux <code@istique.net> | 2008-09-07 21:55:13 +0200 |
---|---|---|
committer | Steve Frécinaux <code@istique.net> | 2008-09-07 22:05:51 +0200 |
commit | 5d3e2f7f57620398df896d9569c5d7c5365f823d (patch) | |
tree | 1d734976d6984236690de77ff4b6eacf31e6b3c7 /lib/git/repo.py | |
parent | befb617d0c645a5fa3177a1b830a8c9871da4168 (diff) | |
download | gitpython-5d3e2f7f57620398df896d9569c5d7c5365f823d.tar.gz |
Allow modifying the project description
Do this:
>>> repo.description = "Foo Bar"
>>> repo.description
'Foo Bar'
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r-- | lib/git/repo.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py index 8cfc2cad..aff595f1 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -62,20 +62,19 @@ class Repo(object): self.git = Git(self.wd) - @property - def description(self): - """ - The project's description. Taken verbatim from GIT_REPO/description - - Returns - str - """ - try: - f = open(os.path.join(self.path, 'description')) - result = f.read() - return result.rstrip() - finally: - f.close() + # Description property + def _get_description(self): + filename = os.path.join(self.path, 'description') + return file(filename).read().rstrip() + + def _set_description(self, descr): + filename = os.path.join(self.path, 'description') + file(filename, 'w').write(descr+'\n') + + description = property(_get_description, _set_description, + doc="the project's description") + del _get_description + del _set_description @property def heads(self): |