| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
|
|
|||
| 2 | # ----------------------------------------------------------------------------- |
||
| 3 | # Copyright (c) 2015 Yann Lanthony |
||
| 4 | # Copyright (c) 2017-2018 Spyder Project Contributors |
||
| 5 | # |
||
| 6 | # Licensed under the terms of the MIT License |
||
| 7 | # (See LICENSE.txt for details) |
||
| 8 | # ----------------------------------------------------------------------------- |
||
| 9 | |||
| 10 | # Standard library imports |
||
| 11 | import os |
||
| 12 | import time |
||
| 13 | from os.path import normpath, join, dirname |
||
| 14 | |||
| 15 | |||
| 16 | PROJECT_DIR = normpath(dirname(dirname(__file__))) |
||
| 17 | EXAMPLES_DIR = normpath(join(PROJECT_DIR, 'examples')) |
||
| 18 | |||
| 19 | |||
| 20 | def example(*paths): |
||
| 21 | """Get path to an example.""" |
||
| 22 | |||
| 23 | return normpath(join(dirname(__file__), '..', 'examples', *paths)) |
||
| 24 | |||
| 25 | |||
| 26 | def touch(file): |
||
| 27 | """Touch a file.""" |
||
| 28 | |||
| 29 | with open(file, 'a') as f: |
||
| 30 | os.utime(file, None) |
||
| 31 | |||
| 32 | |||
| 33 | def await_condition(condition, timeout=2000): |
||
| 34 | """Return True if a condition is met in the given timeout period""" |
||
| 35 | |||
| 36 | for _ in range(timeout): |
||
| 37 | if condition(): |
||
| 38 | return True |
||
| 39 | time.sleep(0.001) |
||
| 40 | return False |
||
| 41 | |||
| 43 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.