return project root or None. if not found
(filename)
| 151 | |
| 152 | |
| 153 | def findSwiftModuleRoot(filename): |
| 154 | """return project root or None. if not found""" |
| 155 | filename = os.path.abspath(filename) |
| 156 | directory = os.path.dirname(filename) |
| 157 | flagFile = None |
| 158 | compileFile = None |
| 159 | while directory and directory != "/": |
| 160 | p = os.path.join(directory, ".swiftflags") |
| 161 | if os.path.isfile(p): |
| 162 | return ( |
| 163 | directory, |
| 164 | p, |
| 165 | compileFile, |
| 166 | ) # prefer use swiftflags file as module root directory |
| 167 | |
| 168 | if compileFile is None: |
| 169 | p = os.path.join(directory, ".compile") |
| 170 | if os.path.isfile(p): |
| 171 | compileFile = p |
| 172 | |
| 173 | if isProjectRoot(directory): |
| 174 | break |
| 175 | else: |
| 176 | directory = os.path.dirname(directory) |
| 177 | else: |
| 178 | return (None, flagFile, compileFile) |
| 179 | |
| 180 | return (directory, flagFile, compileFile) |
| 181 | |
| 182 | |
| 183 | def filekey(filename): |
no test coverage detected