factor out file type detection
@@ -30,12 +30,8 @@ file_types = {
file_type = None
-def read(filename):
-
- global file_type
-
+def determine_file_type(filename) :
file_type = file_types["ascii"]
-
filename_parts = filename.split('.')
if len(filename_parts) > 1 :
type_suffix = filename_parts[-2]
@@ -44,6 +40,15 @@ def read(filename):
elif type_suffix in file_types.keys():
file_type = file_types[type_suffix]
+ return file_type
+
+
+def read(filename):
+
+ global file_type
+
+ file_type = determine_file_type(filename)
+
with open_file(filename) as f:
mesh = read_buffer(f)
return mesh
