Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2023-05-20 20:01:22 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2023-05-23 17:12:11 +0300
commit2e62f47252fd09c954ce4b3adc110414ce816a4d (patch)
tree4a3ac566b2759a89759216e33aa312a144aba814
parent9658ffbf216528b5a2b306e9204b531942409c9a (diff)
Add a simple way of grouping packages for maintainership
Define a team with a line starting with '@', e.g.: @team Maintainer1/Maintainer2 Then @team can be referred in a packages maintainer list, as shorthand for that list of maintainers. Also ignore lines starting with '#' in maintainer list as comments
-rw-r--r--calm/maintainers.py126
1 files changed, 85 insertions, 41 deletions
diff --git a/calm/maintainers.py b/calm/maintainers.py
index d0497cb..9809522 100644
--- a/calm/maintainers.py
+++ b/calm/maintainers.py
@@ -151,46 +151,12 @@ def add_directories(mlist, homedirs):
@utils.mtime_cache
def _read_pkglist(pkglist):
mpkgs = {}
+ teams = {}
with open(pkglist) as f:
for (i, l) in enumerate(f):
- orphaned = False
- l = l.rstrip()
-
- # match lines of the form '<package> <maintainer(s)|status>'
- match = re.match(r'^(\S+)\s+(.+)$', l)
- if match:
- pkg = match.group(1)
- rest = match.group(2)
-
- # does rest starts with a status in all caps?
- status_match = re.match(r'^([A-Z]{2,})\b.*$', rest)
- if status_match:
- status = status_match.group(1)
-
- # packages marked as 'OBSOLETE' are obsolete
- if status == 'OBSOLETE':
- # obsolete packages have no maintainer
- #
- # XXX: perhaps disallow even trusties to upload (or
- # warn if they try?)
- m = ''
-
- # orphaned packages are assigned to 'ORPHANED'
- elif status == 'ORPHANED':
- m = status
- orphaned = True
-
- # also add any previous maintainer(s) listed
- prevm = re.match(r'^ORPHANED\s\((.*)\)', rest)
- if prevm:
- m = m + '/' + prevm.group(1)
- else:
- logging.error("unknown package status '%s' in line %s:%d: '%s'" % (status, pkglist, i, l))
- continue
- else:
- m = rest
+ def _split_maintainer_names(m, teams=None):
# joint maintainers are separated by '/'
maintainers = list()
for name in m.split('/'):
@@ -206,15 +172,83 @@ def _read_pkglist(pkglist):
try:
name.encode('ascii')
except UnicodeError:
- logging.error("non-ascii maintainer name '%s' in line %s:%d, skipped" % (rest, pkglist, i))
+ logging.error("non-ascii maintainer name '%s' in %s:%d: '%s', skipped" % (name, pkglist, i, l))
continue
- maintainers.append(name)
+ if name.startswith('@'):
+ if teams and name in teams:
+ for n in teams[name]:
+ if n not in maintainers:
+ maintainers.append(n)
+ else:
+ logging.error("unknown team '%s' in %s:%d: '%s', skipped" % (name, pkglist, i, l))
+ else:
+ # avoid adding name if it's already in the list (a set
+ # is not appropriate here, as we have the concept of
+ # 'first named maintainer'
+ if name not in maintainers:
+ maintainers.append(name)
+
+ return maintainers
+
+ if l.startswith('#'):
+ # comment
+ continue
+ elif l.startswith('@'):
+ # 'team' definition of the form '@<team> <maintainer(s)>'
+ match = re.match(r'^(\S+)\s+(.+)$', l)
+ if match:
+ team = match.group(1)
+ rest = match.group(2)
+
+ teams[team] = _split_maintainer_names(rest)
+ continue
+ else:
+ # package
+ orphaned = False
+ l = l.rstrip()
+
+ # match lines of the form '<package> <maintainer(s)|status>'
+ match = re.match(r'^(\S+)\s+(.+)$', l)
+ if match:
+ pkg = match.group(1)
+ rest = match.group(2)
+
+ # does rest starts with a status in all caps?
+ status_match = re.match(r'^([A-Z]{2,})\b.*$', rest)
+ if status_match:
+ status = status_match.group(1)
+
+ # packages marked as 'OBSOLETE' are obsolete
+ if status == 'OBSOLETE':
+ # obsolete packages have no maintainer
+ #
+ # XXX: perhaps disallow even trusties to upload (or
+ # warn if they try?)
+ m = ''
+
+ # orphaned packages are assigned to 'ORPHANED'
+ elif status == 'ORPHANED':
+ m = status
+ orphaned = True
+
+ # also add any previous maintainer(s) listed
+ prevm = re.match(r'^ORPHANED\s\((.*)\)', rest)
+ if prevm:
+ m = m + '/' + prevm.group(1)
+ else:
+ logging.error("unknown package status '%s' in line %s:%d: '%s'" % (status, pkglist, i, l))
+ continue
+ else:
+ m = rest
- mpkgs[pkg] = MaintainerPackage(pkg, maintainers, orphaned)
+ maintainers = _split_maintainer_names(m, teams)
- else:
- logging.error("unrecognized line in %s:%d: '%s'" % (pkglist, i, l))
+ mpkgs[pkg] = MaintainerPackage(pkg, maintainers, orphaned)
+ continue
+
+ # couldn't handle the line
+ logging.error("unrecognized line in %s:%d: '%s'" % (pkglist, i, l))
return mpkgs
@@ -259,3 +293,13 @@ def update_reminder_times(mlist):
# a list of all packages
def all_packages(pkglist):
return pkg_list(pkglist).keys()
+
+
+#
+#
+#
+
+if __name__ == "__main__":
+ from . import common_constants
+ p = pkg_list(common_constants.PKGMAINT)
+ print(p['xwininfo'].maintainers())