diff options
author | Sofian Brabez <sbz@FreeBSD.org> | 2012-11-05 21:14:54 +0000 |
---|---|---|
committer | Sofian Brabez <sbz@FreeBSD.org> | 2012-11-05 21:14:54 +0000 |
commit | f765f7580387c0a643d86898eab11314bce5cd88 (patch) | |
tree | 8cf3c149c54b4c64bf56d739f8c705ec69b4a0ef /Tools/scripts | |
parent | 0cc883c99031ed42e14fa0a52139c8ab00545e78 (diff) |
Notes
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/getpatch | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Tools/scripts/getpatch b/Tools/scripts/getpatch index 9c278ccd0086..baf762cd828b 100755 --- a/Tools/scripts/getpatch +++ b/Tools/scripts/getpatch @@ -29,6 +29,8 @@ # MAINTAINER= sbz@FreeBSD.org import argparse +import codecs +import locale import re import sys if sys.version_info.major == 3: @@ -49,6 +51,7 @@ class GetPatch(object): self.url = str() self.patch = str() self.output_stdout = False + self.default_locale = locale.getdefaultlocale()[1].lower() def fetch(self, *largs, **kwargs): raise NotImplementedError() @@ -56,8 +59,8 @@ class GetPatch(object): def write(self, filename, data): if filename.endswith(('.patch', '.txt')): filename = filename[:filename.rindex('.')]+'.diff' - f=open(filename, 'w') - f.write(data.decode()) + f=codecs.open(filename, encoding=self.default_locale, mode='w') + f.write(data.decode(self.default_locale)) f.close() self.out("[+] %s created" % filename) @@ -79,7 +82,7 @@ class GetPatch(object): data = urllib2.urlopen(url).read() if self.output_stdout: - sys.stdout.write(data.decode()) + sys.stdout.write(data.decode(self.default_locale)) else: self.write(p, data) |