mirror of
https://github.com/miguelmota/cointop
synced 2024-11-18 15:25:31 +00:00
01b248ee82
Former-commit-id: 03f60c917e961b9a602201f44db08d96f9633063 [formerly 03f60c917e961b9a602201f44db08d96f9633063 [formerly ebc717d2c1907fc7a7840d674e260a9a033b4554 [formerly 664ed54783c9fdfd300eb39fd4b4a648a410659f]]] Former-commit-id: aac9a01875dc0f2bb9cafdf6a70743e0268c0475 Former-commit-id: 587aa697ce2b26cd6a11406742349b60abad2c11 [formerly 61857f48e24c87948a072aa86c331f0a644bc26e] Former-commit-id: 0690a6a5fce4865803e25015fb141e316279bf8f
55 lines
1.1 KiB
Python
55 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import re
|
|
import os
|
|
import io
|
|
|
|
copyright = """// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
|
// Use of this source code is governed by a MIT license that can
|
|
// be found in the LICENSE file.
|
|
|
|
"""
|
|
|
|
exclude_dirs = [".git", "_docs"]
|
|
exclude_files = []
|
|
include_dirs = [".", "debug", "extra", "test", "_example"]
|
|
|
|
|
|
def is_target(fpath):
|
|
if os.path.splitext(fpath)[-1] == ".go":
|
|
return True
|
|
return False
|
|
|
|
|
|
def update_copyright(fpath):
|
|
print("processing " + fpath)
|
|
f = io.open(fpath, 'r', encoding='utf-8')
|
|
fstr = f.read()
|
|
f.close()
|
|
|
|
# remove old
|
|
m = re.search('^// Copyright .+?\r?\n\r?\n', fstr, re.MULTILINE|re.DOTALL)
|
|
if m:
|
|
fstr = fstr[m.end():]
|
|
|
|
# add new
|
|
fstr = copyright + fstr
|
|
f = io.open(fpath, 'w',encoding='utf-8')
|
|
f.write(fstr)
|
|
f.close()
|
|
|
|
|
|
def main():
|
|
for d in include_dirs:
|
|
files = [
|
|
os.path.join(d, f) for f in os.listdir(d)
|
|
if os.path.isfile(os.path.join(d, f))
|
|
]
|
|
for f in files:
|
|
if is_target(f):
|
|
update_copyright(f)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|