summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2011-12-02 16:55:46 (GMT)
committerLuke Macken <lmacken@redhat.com>2011-12-02 16:55:46 (GMT)
commit8ab8a19784cacc8b88d4daf5c2580095558a8c90 (patch)
treec2c8f0de79b64b81923f044c7eabdf1efb4662fb
parenta12f6edb47bcd41d5829bdb3065f019917e6b54c (diff)
downloadfedoracommunity-8ab8a19784cacc8b88d4daf5c2580095558a8c90.zip
fedoracommunity-8ab8a19784cacc8b88d4daf5c2580095558a8c90.tar.gz
fedoracommunity-8ab8a19784cacc8b88d4daf5c2580095558a8c90.tar.xz
Comments are good
-rw-r--r--fedoracommunity/widgets/package/sources.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/fedoracommunity/widgets/package/sources.py b/fedoracommunity/widgets/package/sources.py
index 74aa5e1..39e8ea8 100644
--- a/fedoracommunity/widgets/package/sources.py
+++ b/fedoracommunity/widgets/package/sources.py
@@ -17,6 +17,7 @@ from package import TabWidget
log = logging.getLogger(__name__)
class FedoraGitRepo(object):
+ """ An abstraction for working with packages in the Fedora Git repos """
def __init__(self, package, branch='master'):
self.package = package
@@ -30,8 +31,11 @@ class FedoraGitRepo(object):
self.repo = git.Repo(self.repo_path)
def _run(self, cmd, **kw):
- # if no working directory is specified, default to inside the
- # repo for this package & branch
+ """ Run a shell command and return stdout.
+
+ If no `cwd` is specified, default to inside the repo for this
+ package & branch.
+ """
if 'cwd' not in kw:
kw['cwd'] = self.repo_path
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
@@ -42,13 +46,16 @@ class FedoraGitRepo(object):
return out
def clone_repo(self):
+ """ Create a fresh clone of this package's git repository """
self._run('fedpkg clone --anonymous --branches ' + self.package,
cwd=config.get('git_repo_path'))
def get_spec(self):
+ """ Return the contents of this package's RPM spec file """
return self.repo.tree()[self.package + '.spec'].data_stream.read()
def get_patches(self):
+ """ Return a dictionary of all patches for this package """
patches = {}
for patch in [blob for blob in self.repo.tree().traverse()
if blob.name.endswith('.patch')]:
@@ -59,10 +66,12 @@ class FedoraGitRepo(object):
]
return patches
- def get_patch(self, filename):
- return self.repo.tree()[filename].data_stream.read()
+ def get_patch(self, patch):
+ """ Return the contents of a specific patch """
+ return self.repo.tree()[patch].data_stream.read()
def get_patch_changelog(self, patch):
+ """ Return a list of the changes made to this patch """
commits = []
current = {}
in_commit = False
@@ -85,12 +94,15 @@ class FedoraGitRepo(object):
return commits
def get_diffstat(self, patch='*.patch'):
+ """ Return the output of diffstat on a given patch, or all patches """
return self._run('diffstat %s' % patch)
def get_creation_time(self, filename):
+ """ Return a datetime object for the date a given file was created """
date = ' '.join(self.repo.git.log(filename, reverse=True).split('\n')[2].split()[1:-1])
return DateTimeDisplay(date, format='%a %b %d %H:%M:%S %Y').datetime
+
class Sources(TabWidget):
tabs = OrderedDict([
('Spec', 'package.sources.spec'),