Mercurial > repos > greg > icqsol_create_shape
comparison icqsol_utils.py @ 6:cda30ae2e9d7 draft
Uploaded
author | greg |
---|---|
date | Wed, 09 Dec 2015 11:01:10 -0500 |
parents | bdf03ec93415 |
children | 8df65e37d12a |
comparison
equal
deleted
inserted
replaced
5:cb3e79d1e85e | 6:cda30ae2e9d7 |
---|---|
1 import os | 1 import os |
2 import sys | 2 import sys |
3 import tempfile | 3 import tempfile |
4 | 4 |
5 PLY = 'ply' | |
5 POLYDATA = 'POLYDATA' | 6 POLYDATA = 'POLYDATA' |
7 VTK = 'vtk' | |
6 | 8 |
7 | 9 |
8 def asbool(val): | 10 def asbool(val): |
9 return str(val).lower() in ['yes', 'true'] | 11 return str(val).lower() in ['yes', 'true'] |
10 | 12 |
12 def get_format_and_type(galaxy_ext): | 14 def get_format_and_type(galaxy_ext): |
13 # Define the output file format and type. | 15 # Define the output file format and type. |
14 format = None | 16 format = None |
15 datatype = None | 17 datatype = None |
16 if galaxy_ext in ['vtkascii', 'vtkbinary']: | 18 if galaxy_ext in ['vtkascii', 'vtkbinary']: |
17 format = 'vtk' | 19 format = VTK |
18 elif galaxy_ext in ['plyascii', 'plybinary']: | 20 elif galaxy_ext in ['plyascii', 'plybinary']: |
19 format = 'ply' | 21 format = PLY |
20 if galaxy_ext in ['vtkascii', 'plyascii']: | 22 if galaxy_ext in ['vtkascii', 'plyascii']: |
21 datatype = 'ascii' | 23 datatype = 'ascii' |
22 elif galaxy_ext in ['vtkbinary', 'plybinary']: | 24 elif galaxy_ext in ['vtkbinary', 'plybinary']: |
23 datatype = 'binary' | 25 datatype = 'binary' |
24 return format, datatype | 26 return format, datatype |
46 | 48 |
47 def get_tempfilename(dir=None, suffix=None): | 49 def get_tempfilename(dir=None, suffix=None): |
48 """ | 50 """ |
49 Return a temporary file name. | 51 Return a temporary file name. |
50 """ | 52 """ |
51 fd, name = tempfile.mkstemp(suffix=suffix, dir=dir) | 53 if suffix is None: |
54 s = None | |
55 elif suffix.startswith('.'): | |
56 s = suffix | |
57 else: | |
58 s = '.%s' % suffix | |
59 fd, name = tempfile.mkstemp(suffix=s, dir=dir) | |
52 os.close(fd) | 60 os.close(fd) |
53 return name | 61 return name |
54 | 62 |
55 | 63 |
56 def get_temporary_file_path(tmp_dir, file_extension): | 64 def get_temporary_file_path(tmp_dir, file_extension): |