Return contents from a file located at *path*. If *path* is a tuple instead of a string, os.path.join will be used to make a path. If *binary* is true, the file will be opened in binary mode.
(path, binary=False)
| 100 | assert os.path.getsize(path) == size |
| 101 | |
| 102 | def read_file(path, binary=False): |
| 103 | """Return contents from a file located at *path*. |
| 104 | |
| 105 | If *path* is a tuple instead of a string, os.path.join will be used to |
| 106 | make a path. If *binary* is true, the file will be opened in binary |
| 107 | mode. |
| 108 | """ |
| 109 | if isinstance(path, tuple): |
| 110 | path = os.path.join(*path) |
| 111 | mode = 'rb' if binary else 'r' |
| 112 | encoding = None if binary else "utf-8" |
| 113 | with open(path, mode, encoding=encoding) as fp: |
| 114 | return fp.read() |
| 115 | |
| 116 | def rlistdir(path): |
| 117 | res = [] |
no test coverage detected
searching dependent graphs…