| 39 | ] |
| 40 | |
| 41 | def replace_rc_version (version): |
| 42 | source_rc_path = rc_path |
| 43 | target_rc_path = rc_path + '.tmp' |
| 44 | with open(target_rc_path, 'w', encoding='utf-16-le') as fw, open(source_rc_path, 'r', encoding=rc_encoding) as f: |
| 45 | for line in f: |
| 46 | m = version_str.match (line) |
| 47 | if m: |
| 48 | line = re.sub (version_str, r'\g<1>{}\3'.format ('.'.join (version)), line) |
| 49 | for pattern in comma_version_str: |
| 50 | m = pattern.match (line) |
| 51 | if m: |
| 52 | line = re.sub (pattern, r'\g<1>{}\3'.format (','.join (version) + ',0'), line) |
| 53 | fw.write (line) |
| 54 | os.remove (source_rc_path) |
| 55 | os.rename (target_rc_path, source_rc_path) |
| 56 | |
| 57 | def zip(src, dst): |
| 58 | zf = zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED) |