[Mesa-dev] [PATCH] mesa: improve error messaging for format CSV parser

Jason Ekstrand jason at jlekstrand.net
Mon Jan 26 09:59:12 PST 2015


On Mon, Jan 26, 2015 at 2:35 AM, Tapani Pälli <tapani.palli at intel.com>
wrote:

> Patch adds 2 error messages that point user directly to fix
> mispelled or impossible swizzle field for a format.
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
>  src/mesa/main/format_info.py   | 2 +-
>  src/mesa/main/format_parser.py | 7 ++++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
> index fe2063d..99d438d 100644
> --- a/src/mesa/main/format_info.py
> +++ b/src/mesa/main/format_info.py
> @@ -58,7 +58,7 @@ def get_gl_base_format(fmat):
>     elif fmat.has_channel('i') and fmat.num_channels() == 1:
>        return 'GL_INTENSITY'
>     else:
> -      assert False
> +      sys.exit("error, could not determine base format for " + fmat.name
> + ", check swizzle");
>

It would be a little nicer to do "... format for {0}, check swizzle".format(
fmat.name)

Other than that, I like this.

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>


>
>  def get_gl_data_type(fmat):
>     if fmat.is_compressed():
> diff --git a/src/mesa/main/format_parser.py
> b/src/mesa/main/format_parser.py
> index 522bce3..11184f7 100755
> --- a/src/mesa/main/format_parser.py
> +++ b/src/mesa/main/format_parser.py
> @@ -24,6 +24,8 @@
>  # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
>  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>
> +import sys
> +
>  VOID = 'x'
>  UNSIGNED = 'u'
>  SIGNED = 's'
> @@ -562,7 +564,10 @@ def parse(filename):
>           block_height = int(fields[3])
>           colorspace = fields[9]
>
> -         swizzle = Swizzle(fields[8])
> +         try:
> +            swizzle = Swizzle(fields[8])
> +         except:
> +            sys.exit("error parsing swizzle for format " + name)
>           channels = _parse_channels(fields[4:8], layout, colorspace,
> swizzle)
>
>           yield Format(name, layout, block_width, block_height, channels,
> swizzle, colorspace)
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150126/13e9d4af/attachment.html>


More information about the mesa-dev mailing list