From: Dmitry Selyutin Date: Thu, 14 Sep 2017 16:37:26 +0000 (+0300) Subject: special "module not found" error X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1f6dc51123e352af74c6fe5b47ad8a57baf9abef;p=gnulib.git special "module not found" error --- diff --git a/pygnulib/error.py b/pygnulib/error.py index 4504c0fbbb..a09a095926 100644 --- a/pygnulib/error.py +++ b/pygnulib/error.py @@ -65,6 +65,14 @@ class M4BaseMismatchError(Exception): +class GnulibModuleNotFoundError(Exception): + """module not found""" + def __init__(self, name): + fmt = "module not found: {0}" + super().__init__(fmt.format(name)) + + + class UnknownLicenseError(Exception): """module lacks a license""" def __init__(self, module): diff --git a/pygnulib/filesystem.py b/pygnulib/filesystem.py index 81f17b0381..21a4c7791e 100644 --- a/pygnulib/filesystem.py +++ b/pygnulib/filesystem.py @@ -7,6 +7,7 @@ import os as _os_ from .error import type_assert as _type_assert_ +from .error import GnulibModuleNotFoundError as _GnulibModuleNotFoundError_ from .config import Base as _BaseConfig_ from .module import Base as _BaseModule_ from .module import File as _FileModule_ @@ -123,7 +124,10 @@ class GnulibGit(Directory): if name in GnulibGit._EXCLUDE_: raise ValueError("illegal module name") path = _os_.path.join(self["modules"], name) - return _FileModule_(path, name=name) if full else _BaseModule_(name) + try: + return _FileModule_(path, name=name) if full else _BaseModule_(name) + except FileNotFoundError: + raise _GnulibModuleNotFoundError_(name) def modules(self, full=True):