MCPcopy Index your code
hub / github.com/numpy/numpy / main

Function main

tools/changelog.py:109–177  ·  view source on GitHub ↗
(token, revision_range)

Source from the content-addressed store, hash-verified

107
108
109def main(token, revision_range):
110 lst_release, cur_release = [r.strip() for r in revision_range.split('..')]
111
112 github = Github(token)
113 github_repo = github.get_repo('numpy/numpy')
114
115 # document authors
116 authors = get_authors(revision_range)
117 heading = "Contributors"
118 print()
119 print(heading)
120 print("=" * len(heading))
121 print(author_msg % len(authors))
122
123 for s in authors:
124 print('* ' + s)
125
126 # document pull requests
127 pull_requests = get_pull_requests(github_repo, revision_range)
128 heading = "Pull requests merged"
129 pull_msg = "* `#{0} <{1}>`__: {2}"
130
131 print()
132 print(heading)
133 print("=" * len(heading))
134 print(pull_request_msg % len(pull_requests))
135
136 def backtick_repl(matchobj):
137 """repl to add an escaped space following a code block if needed"""
138 if matchobj.group(2) != ' ':
139 post = r'\ ' + matchobj.group(2)
140 else:
141 post = matchobj.group(2)
142 return '``' + matchobj.group(1) + '``' + post
143
144 for pull in pull_requests:
145 # sanitize whitespace
146 title = re.sub(r"\s+", " ", pull.title.strip())
147
148 # substitute any single backtick not adjacent to a backtick
149 # for a double backtick
150 title = re.sub(
151 r"(?P<pre>(?:^|(?<=[^`])))`(?P<post>(?=[^`]|$))",
152 r"\g<pre>``\g<post>",
153 title
154 )
155 # add an escaped space if code block is not followed by a space
156 title = re.sub(r"``(.*?)``(.)", backtick_repl, title)
157
158 # sanitize asterisks
159 title = title.replace('*', '\\*')
160
161 if len(title) > 60:
162 remainder = re.sub(r"\s.*$", "...", title[60:])
163 if len(remainder) > 20:
164 # just use the first 80 characters, with ellipses.
165 # note: this was previously bugged,
166 # assigning to `remainder` rather than `title`

Callers 1

changelog.pyFile · 0.70

Calls 6

get_authorsFunction · 0.85
get_pull_requestsFunction · 0.85
stripMethod · 0.80
splitMethod · 0.80
replaceMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…