aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageialinux-online.org>2015-11-01 09:40:16 +0100
committerPapoteur <papoteur@mageialinux-online.org>2015-11-01 09:40:16 +0100
commit751cee16864784c8ff3ec2a0c74cb0958012a987 (patch)
treeeadebe5ea9cc5d19d07c3698062979d90a0b09dc /MgaRepo
parent85e0448d6d4994a21309a55be13a0a58e84ea761 (diff)
downloadmgarepo-751cee16864784c8ff3ec2a0c74cb0958012a987.tar
mgarepo-751cee16864784c8ff3ec2a0c74cb0958012a987.tar.gz
mgarepo-751cee16864784c8ff3ec2a0c74cb0958012a987.tar.bz2
mgarepo-751cee16864784c8ff3ec2a0c74cb0958012a987.tar.xz
mgarepo-751cee16864784c8ff3ec2a0c74cb0958012a987.zip
Reading and writing spec file in utf-8 encoding in log.py
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/log.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/MgaRepo/log.py b/MgaRepo/log.py
index 2622f72..96be56d 100644
--- a/MgaRepo/log.py
+++ b/MgaRepo/log.py
@@ -607,9 +607,8 @@ def get_changelog(pkgdirurl, another=None, svn=True, rev=None, size=None,
def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None,
submit=False, sort=False, template=None, macros=[], exported=None):
- fi = open(specfile)
- spec, oldchlog = split_spec_changelog(fi)
- fi.close()
+ with open(specfile, encoding = 'utf-8') as fi:
+ spec, oldchlog = split_spec_changelog(fi)
another = None
if config.getbool("log", "merge-spec", False):
another = oldchlog
@@ -617,12 +616,12 @@ def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None,
chlog = get_changelog(pkgdirurl, another=another, rev=rev, size=size,
submit=submit, sort=sort, template=template, macros=macros,
exported=exported, oldlog=True)
- fo = open(specfile, "w")
- fo.writelines(spec)
- fo.write("\n\n%changelog\n")
- fo.writelines(chlog)
- fo.close()
-
+ print(spec)
+ with open(specfile, "w", encoding='utf-8') as fo:
+ fo.writelines(spec)
+ fo.write("\n\n%changelog\n")
+ fo.writelines(chlog)
+
if __name__ == "__main__":
l = svn2rpm(sys.argv[1])
print(l)