Gentoo Archives: gentoo-portage-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] bin/doins.py: implement install -p option (bug 642632)
Date: Sat, 30 Dec 2017 21:46:08
Message-Id: CAJ0EP40gMDafByhp2JG9pWVbh+rnWU2x8t6cP8H+JE=wbScuWw@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH v2] bin/doins.py: implement install -p option (bug 642632) by Zac Medico
1 On Fri, Dec 29, 2017 at 7:19 PM, Zac Medico <zmedico@g.o> wrote:
2 > +def _set_timestamps(source_stat, dest):
3 > + """Apply timestamps from source_stat to dest.
4 > +
5 > + Args:
6 > + source_stat: stat result for the source file.
7 > + dest: path to the dest file.
8 > + """
9 > + os.utime(dest, (source_stat.st_atime, source_stat.st_mtime))
10 > +
11 > +
12 > +if sys.version_info >= (3, 3):
13 > + def _set_timestamps_ns(source_stat, dest):
14 > + os.utime(dest, ns=(source_stat.st_atime_ns, source_stat.st_mtime_ns))
15 > +
16 > + _set_timestamps_ns.__doc__ = _set_timestamps.__doc__
17 > + _set_timestamps = _set_timestamps_ns
18 > +
19 > +
20
21 This seems weirdly complex. I guess the goal was to reduce the
22 sys.version_info check to once per import?
23
24 The __doc__ trick is nifty, but I'm not sure I would ever want to use it myself.
25
26 Anyway, just my thoughts as an unpracticed python programmer. It looks
27 like this code will get the job done.

Replies