Skip to content

Commit b2841c6

Browse files
author
Kurt Yoder
authored
Merge pull request #21 from 1danielcoelho/check_implemented_flags
Handle any unimplemented flag and carry on with a warning
2 parents cb1ae9a + 7296386 commit b2841c6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pywavefront/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,3 @@ def parse_f(self, args):
147147
if i == 0:
148148
v1 = vertex
149149
vlast = vertex
150-
151-
def parse_s(self, args):
152-
# unimplemented
153-
return

pywavefront/parser.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434

3535
import os
3636
import pyglet
37+
import logging
3738

3839
class Parser(object):
3940
"""This defines a generalized parse dispatcher; all parse functions
4041
reside in subclasses."""
42+
strict = False
4143

4244
def read_file(self, file_name):
4345
for line in open(file_name, 'r'):
@@ -63,5 +65,14 @@ def parse(self, line, dir):
6365
args[i] = arg
6466
i += 1
6567

66-
parse_function = getattr(self, 'parse_%s' % line_type)
67-
parse_function(args)
68+
attrib = 'parse_%s' % line_type
69+
70+
if Parser.strict:
71+
parse_function = getattr(self, attrib)
72+
parse_function(args)
73+
elif hasattr(self, attrib):
74+
parse_function = getattr(self, attrib)
75+
parse_function(args)
76+
else:
77+
logging.warning("Unimplemented OBJ format statement '%s' on line '%s'"
78+
% (line_type, line.rstrip()))

0 commit comments

Comments
 (0)