예제 #1
0
파일: __init__.py 프로젝트: rjeschmi/fbuild
        def f(module, include):
            # On case-insensitive but case-preserving filesystems, we need to
            # be careful on how we deal with finding OCaml dependencies. Since
            # OCaml can store a module named List in either list.ml or List.ml,
            # we can't just test if the filename exists since fbuild needs to
            # deal with the exact filenames.  To do that, we'll grab the list
            # of filenames in the directory, then search for the right
            # spelling in that list.

            # Grab the filenames in the directory.
            if include is None:
                dirs = Path.getcwd().listdir()
            else:
                include = Path(include)

                if not include.exists():
                    # We can't search for dependencies in a directory that
                    # doesn't exist, so exit early.
                    return False

                dirs = include.listdir()

            found = False
            for suffix in '.mli', '.ml':
                # Look for the traditional lowercase form.
                path = module[0].lower() + module[1:] + suffix
                if path not in dirs:
                    # That didn't work, so lets try the uppercase form.
                    path = module[0].upper() + module[1:] + suffix
                    if path not in dirs:
                        # Couldn't find it, so just skip this module.
                        continue

                # We found it! Add that file to the dependencies.
                if include is None:
                    deps.append(Path(path))
                else:
                    deps.append(include / path)
                found = True

            return found
예제 #2
0
파일: __init__.py 프로젝트: ACGCross/felix
        def f(module, include):
            # On case-insensitive but case-preserving filesystems, we need to
            # be careful on how we deal with finding OCaml dependencies. Since
            # OCaml can store a module named List in either list.ml or List.ml,
            # we can't just test if the filename exists since fbuild needs to
            # deal with the exact filenames.  To do that, we'll grab the list
            # of filenames in the directory, then search for the right
            # spelling in that list.

            # Grab the filenames in the directory.
            if include is None:
                dirs = Path.getcwd().listdir()
            else:
                include = Path(include)

                if not include.exists():
                    # We can't search for dependencies in a directory that
                    # doesn't exist, so exit early.
                    return False

                dirs = include.listdir()

            found = False
            for suffix in '.mli', '.ml':
                # Look for the traditional lowercase form.
                path = module[0].lower() + module[1:] + suffix
                if path not in dirs:
                    # That didn't work, so lets try the uppercase form.
                    path = module[0].upper() + module[1:] + suffix
                    if path not in dirs:
                        # Couldn't find it, so just skip this module.
                        continue

                # We found it! Add that file to the dependencies.
                if include is None:
                    deps.append(Path(path))
                else:
                    deps.append(include / path)
                found = True

            return found