| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """C-2a-4a 补丁:
- 1. gate-lock.vue L126 .reward-text on-dark 文字 rgba(143,197,232,0.5) -> rgba(251,146,60,0.5)
- 2. 执行首跑中断后未完成的两个文件(FamilyRelationGraph / DimensionArticles)
- """
- import io
- import sys
- ORANGE = '$brand-primary'
- ORANGE_LIGHT = '$brand-primary-light'
- RESIDUAL_RE = __import__('re').compile(
- r'(?<![0-9A-Fa-f])#(?:5B9BD5|3A7CC4|3A7CC2|4A9BD7|63B3ED|8FC5E8)(?![0-9A-Fa-f])', __import__('re').I)
- RESIDUAL_RGBA = __import__('re').compile(r'rgba\((?:91, ?155, ?213|74, ?155, ?215|143, ?197, ?232)')
- # (page, [(old, new, expect)], [(old, new, expect) script], need_lang)
- JOBS = [
- ('components/gate-lock.vue',
- [('color: rgba(143,197,232,0.5);', 'color: rgba(251,146,60,0.5);', 1)],
- [], False),
- ('components/FamilyRelationGraph.vue',
- [],
- [("home: '#5B9BD5',", "home: '#F97316',", 1)],
- False),
- ('components/DimensionArticles.vue',
- [],
- [("linear-gradient(135deg, #5B9BD5, #8FC5E8)",
- "'linear-gradient(135deg, %s, %s)'" % (ORANGE, ORANGE_LIGHT), 1)],
- False),
- ]
- def main():
- for page, globals_, script, _lang in JOBS:
- src = io.open(page, encoding='utf-8').read()
- print('== %s ==' % page)
- for old, new, expect in globals_:
- n = src.count(old)
- if n != expect:
- raise RuntimeError('%s: hit=%d(要求 %d):: %s' % (page, n, expect, old))
- src = src.replace(old, new)
- print(' %-52s -> %s x%d' % (old, new, n))
- for old, new, expect in script:
- n = src.count(old)
- if n != expect:
- raise RuntimeError('%s: 脚本区 %s hit=%d(要求 %d)' % (page, old, n, expect))
- src = src.replace(old, new)
- print(' [script] %-44s -> %s x%d' % (old, new, n))
- io.open(page, 'w', encoding='utf-8', newline='').write(src)
- residual = RESIDUAL_RE.findall(src) + RESIDUAL_RGBA.findall(src)
- if residual:
- raise RuntimeError('%s: 终检残留 %s' % (page, residual))
- print('C-2a-4a 补丁完毕')
- if __name__ == '__main__':
- sys.exit(main())
|