(filename, line_re, edit)
| 138 | return output.decode('utf-8') |
| 139 | |
| 140 | def update_file(filename, line_re, edit): |
| 141 | infile = open(filename, 'r') |
| 142 | buffer = [] |
| 143 | |
| 144 | changed = False |
| 145 | for line in infile: |
| 146 | if not changed: |
| 147 | match = line_re.search(line) |
| 148 | if match: |
| 149 | changed = edit(buffer, match, line) |
| 150 | if changed is None: |
| 151 | return False |
| 152 | continue |
| 153 | buffer.append(line) |
| 154 | if not changed: |
| 155 | raise Exception('Could not find %s in %s' % (line_re, filename)) |
| 156 | with open(filename, 'w') as f: |
| 157 | f.write(''.join(buffer)) |
| 158 | return True |
| 159 | |
| 160 | |
| 161 | # branch types are "release", "stable" and "unstable" |
no test coverage detected
searching dependent graphs…