Gentoo Archives: gentoo-portage-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-portage-dev@l.g.o
Cc: SebastianLuther@×××.de
Subject: Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
Date: Wed, 27 Nov 2013 21:20:53
Message-Id: 201311271620.49611.vapier@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk by SebastianLuther@gmx.de
1 On Wednesday 27 November 2013 05:31:17 SebastianLuther@×××.de wrote:
2 > + if options.write_timestamp:
3 > + timestamp_path = os.path.join(repo_path, "metadata", "timestamp.chk")
4 > + try:
5 > + timestampfile = open(timestamp_path, "w")
6 > + try:
7 > + timestampfile.write(
8 > + time.strftime("%a, %d %b %Y %H:%M:%S +0000",
9 time.gmtime()))
10 > + timestampfile.write("\n")
11 > + finally:
12 > + timestampfile.close()
13
14 use a with block, and merge those writes
15
16 with open(timestamp_path, 'w') as f:
17 f.write(time.strftime('%a, %d %b %Y %H:%M:%S +0000\n', time.gmtime()))
18 -mike

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies