in libmozdata/HGFileInfo.py [0:0]
def get(self, path, utc_ts_from=None, utc_ts_to=None, authors=[]):
if utc_ts_to is None:
revision = hgmozilla.Revision.get_revision(self.channel, self.node)
assert self.date_type in revision
assert isinstance(revision[self.date_type], list)
utc_ts_to = revision[self.date_type][0]
for result in self.results:
result.wait()
author_pattern = re.compile(r"<([^>]+)>")
email_pattern = re.compile(r"<?([\w\-\._\+%]+@[\w\-\._\+%]+)>?")
entries = self.data[path]
authors_result = {}
bugs = set()
patches = []
for entry in entries:
assert self.date_type in entry
# no pushdate
# TODO: find a way to estimate the pushdate (e.g. (prev + next) / 2 or use the author date)
if entry[self.date_type] == "":
logging.getLogger(__name__).warning(
"Entry for file %s with node %s has no pushdate"
% (path, entry["node"])
)
continue
assert isinstance(entry[self.date_type], list)
utc_date = entry[self.date_type][0]
if (
utc_ts_from is not None and utc_ts_from > utc_date
) or utc_ts_to < utc_date:
continue
m = author_pattern.search(entry["user"])
if m is None:
m = email_pattern.search(entry["user"])
if m:
entry["user"] = m.group(1)
patch_author = entry["user"]
if authors and patch_author not in authors:
continue
if patch_author not in authors_result:
authors_result[patch_author] = {"count": 1, "reviewers": {}}
else:
authors_result[patch_author]["count"] += 1
info_desc = self.__get_info_from_desc(entry["desc"])
starter = info_desc["starter"]
if starter:
bugs.add(info_desc["starter"])
reviewers = info_desc["reviewers"]
if reviewers:
_reviewers = authors_result[patch_author]["reviewers"]
for reviewer in reviewers:
if reviewer not in _reviewers:
_reviewers[reviewer] = 1
else:
_reviewers[reviewer] += 1
patches.append(entry)
return {"authors": authors_result, "bugs": bugs, "patches": patches}