CVS Log Message Encoding
CVS 로그 메시지 인코딩을 cp949에서 utf-8로 바꿔주는 방법 ¶동일한 CVS 저장소를 윈도우와 리눅스에서 사용할 경우에 로그 메시지의 인코딩이 달라서 문제가 되는 경우가 있습니다. (물론 어떤 경우에도 인코딩이 다르면 문제겠지만; ) 그럴 때 다음과 같은 스크립트를 쓰면 모든 로그 메시지를 utf-8로 바꿔줍니다.
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
file do_something_about_encoding.py
Title: 인코딩 어쩌구저쩌구.
Desc: 파일의 인코딩에 대해 뭔갈 하는 프로그램.
Author: Son, Kyeong-uk(hey_calm)
$Log: CVSLogMessageEncoding,v $
Revision 1.1 2004/11/13 11:14:26 kss
211.104.178.25;;WkPark;;
Revision 1.2 2004/07/30 04:37:13 kss
211.63.103.71;;hey;;
Revision 1.1 2004/07/29 09:56:04 kss
211.213.198.101;;pyrasis;;
Revision 1.6 2004/07/29 09:02:22 hey_calm
로그 메시지 변경 확인.
Revision 1.5 2004/07/29 08:59:55 hey_calm
로그 메시지를 euc-kr -> utf-8 -> cp949 순서대로 간주하고 인코딩 추측함.
Revision 1.4 2004/07/29 08:15:31 hey_calm
Revision 1.3 2004/07/29 07:58:32 hey_calm
iconv가 실패해도 에러 메시지 찍지 않게 바꿈.
Revision 1.2 2004/07/27 06:05:24 hey_calm
탭을 스페이스로 바꿈.
Revision 1.1 2004/07/27 05:39:57 hey_calm
로그 메시지의 인코딩을 utf-8로 바꿔주는 기능 넣음.
"""
import os, sys
filename = ""
if __name__ == '__main__':
if 1 < len(sys.argv):
filename = sys.argv[1]
file = open(filename, 'r')
source = file.read()
try:
content = unicode(source, "euc-kr").encode("utf-8")
except UnicodeError:
try:
unicode(source, "utf-8").encode("utf-8")
content = None
except UnicodeError:
try:
content = unicode(source, "cp949").encode("utf-8")
except UnicodeError:
content = None
if content is not None:
file = open(filename, "w")
file.write(content)
file.close()
... 생략
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
DEFAULT $CVSROOT/CVSROOT/do_something_about_encoding.py
... 생략
# File format:
#
# [<whitespace>]<filename>[<whitespace><error message>]<end-of-line>
#
# comment lines begin with '#'
do_something_about_encoding.py 로그 메시지 인코딩을 어떻게 좀 하는 프로그램
|