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. |