__init__.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """Minimal, stdlib-only replacement for [`pyfilesystem2`][1] API for use by `fontTools.ufoLib`.
  2. This package is a partial reimplementation of the `fs` package by Will McGugan, used under the
  3. MIT license. See LICENSE.external for details.
  4. Note this only exports a **subset** of the `pyfilesystem2` API, in particular the modules,
  5. classes and functions that are currently used directly by `fontTools.ufoLib`.
  6. It opportunistically tries to import the relevant modules from the upstream `fs` package
  7. when this is available. Otherwise it falls back to the replacement modules within this package.
  8. As of version 4.59.0, the `fonttools[ufo]` extra no longer requires the `fs` package, thus
  9. this `fontTools.misc.filesystem` package is used by default.
  10. Client code can either replace `import fs` with `from fontTools.misc import filesystem as fs`
  11. if that happens to work (no guarantee), or they can continue to use `fs` but they will have
  12. to specify it as an explicit dependency of their project.
  13. [1]: https://github.com/PyFilesystem/pyfilesystem2
  14. """
  15. from __future__ import annotations
  16. try:
  17. __import__("fs")
  18. except ImportError:
  19. from . import _base as base
  20. from . import _copy as copy
  21. from . import _errors as errors
  22. from . import _info as info
  23. from . import _osfs as osfs
  24. from . import _path as path
  25. from . import _subfs as subfs
  26. from . import _tempfs as tempfs
  27. from . import _tools as tools
  28. from . import _walk as walk
  29. from . import _zipfs as zipfs
  30. _haveFS = False
  31. else:
  32. import fs.base as base
  33. import fs.copy as copy
  34. import fs.errors as errors
  35. import fs.info as info
  36. import fs.osfs as osfs
  37. import fs.path as path
  38. import fs.subfs as subfs
  39. import fs.tempfs as tempfs
  40. import fs.tools as tools
  41. import fs.walk as walk
  42. import fs.zipfs as zipfs
  43. _haveFS = True
  44. __all__ = [
  45. "base",
  46. "copy",
  47. "errors",
  48. "info",
  49. "osfs",
  50. "path",
  51. "subfs",
  52. "tempfs",
  53. "tools",
  54. "walk",
  55. "zipfs",
  56. ]