Write a file, and force a timestamp difference of at least one second Notes ----- Python's .pyc files record the timestamp of their compilation with a time resolution of one second. Therefore, we need to force a timestamp difference between .py
(self, filename, content)
| 759 | return module_name, file_name |
| 760 | |
| 761 | def write_file(self, filename, content): |
| 762 | """ |
| 763 | Write a file, and force a timestamp difference of at least one second |
| 764 | |
| 765 | Notes |
| 766 | ----- |
| 767 | Python's .pyc files record the timestamp of their compilation |
| 768 | with a time resolution of one second. |
| 769 | |
| 770 | Therefore, we need to force a timestamp difference between .py |
| 771 | and .pyc, without having the .py file be timestamped in the |
| 772 | future, and without changing the timestamp of the .pyc file |
| 773 | (because that is stored in the file). The only reliable way |
| 774 | to achieve this seems to be to sleep. |
| 775 | |
| 776 | Doesn't seem necessary on Darwin so we make this the exception. |
| 777 | """ |
| 778 | if platform.system().lower() != "darwin": |
| 779 | time.sleep(1.05) |
| 780 | with open(filename, "w", encoding="utf-8") as f: |
| 781 | f.write(squish_text(content)) |
| 782 | |
| 783 | def new_module(self, code): |
| 784 | mod_name, mod_fn = self.get_module() |
no test coverage detected