Debian Codegraph @

release_tools/shared.py

raw symbols SCIP
1 import argparse as ap
2
3 import github
4
5
6 def update_parser_with_common_stuff(parser):
7 parser.add_argument("--owner", default="openscap")
8 group = parser.add_mutually_exclusive_group(required=True)
9 group.add_argument("--auth-token")
10
11
12 def get_milestone(repo, name):
13 milestones = repo.get_milestones()
14 matches = [m for m in milestones if m.title == name]
15 assert len(matches) <= 1, \
16 f"Expected to find at most one milestone {name}, found {len(matches)}"
17 if len(matches) == 0:
18 return None
19 else:
20 return matches[0]
21
22
23 def get_github(args):
24 if args.auth_token is not None:
25 return github.Github(args.auth_token)
26 else:
27 assert 0, "Credentials were not supplied"
28
29
30 def get_repo(github, owner):
31 repo = github.get_repo(f"{owner}/openscap")
32 return repo
33
34
35 def version_type(string):
36 components = string.split(".")
37 shortest_component_len = min([len(x) for x in components])
38 if len(components) != 3 or shortest_component_len == 0:
39 msg = (
40 "Expected version number of form X.Y.Z, where X, Y, Z are strings. "
41 f"Got: '{string}'"
42 )
43 raise ap.ArgumentTypeError(msg)
44 return string