v0.9.1
Functions | Variables
convert Namespace Reference

Functions

def print_progress (iteration, total, decimals=1, bar_length=50)
 
def is_not_h5m (file)
 
def is_older_than_vtk (file)
 
def mb_convert (file)
 

Variables

 parser = argparse.ArgumentParser()
 
 help
 
 nargs
 
 type
 
 int
 
 default
 
 args = parser.parse_args()
 
 file_list = list(ifilterfalse(is_not_h5m, args.file))
 
 N = Value('i', len(file_list))
 
 n = Value('i', 0)
 
 pool = mp.Pool(args.np)
 

Function Documentation

◆ is_not_h5m()

def convert.is_not_h5m (   file)

Definition at line 27 of file convert.py.

27 def is_not_h5m(file):
28  return not file.endswith('h5m')
29 
30 
def is_not_h5m(file)
Definition: convert.py:27

◆ is_older_than_vtk()

def convert.is_older_than_vtk (   file)

Definition at line 31 of file convert.py.

31 def is_older_than_vtk(file):
32  file_vtk = path.splitext(file)[0] + ".vtk"
33  if path.exists(file_vtk):
34  return path.getmtime(file) < path.getmtime(file_vtk)
35  return False
36 
37 
def is_older_than_vtk(file)
Definition: convert.py:31

◆ mb_convert()

def convert.mb_convert (   file)

Definition at line 38 of file convert.py.

38 def mb_convert(file):
39  file = path.splitext(file)[0]
40  p = subprocess.Popen(["mbconvert", file + ".h5m", file + ".vtk"],
41  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
42  (out, err) = p.communicate()
43  if p.returncode:
44  print "\n", err
45  n.value += 1
46  print_progress(n.value, N.value)
47 
48 
def mb_convert(file)
Definition: convert.py:38
def print_progress(iteration, total, decimals=1, bar_length=50)
Definition: convert.py:13

◆ print_progress()

def convert.print_progress (   iteration,
  total,
  decimals = 1,
  bar_length = 50 
)

Definition at line 13 of file convert.py.

13 def print_progress(iteration, total, decimals=1, bar_length=50):
14  str_format = "{0:." + str(decimals) + "f}"
15  percents = str_format.format(100 * (iteration / float(total)))
16  filled_length = int(round(bar_length * iteration / float(total)))
17  bar = '█' * filled_length + '-' * (bar_length - filled_length)
18 
19  sys.stdout.write('\r |%s| %s%s (%s of %s)' %
20  (bar, percents, '%', str(iteration), str(total)))
21 
22  if iteration == total:
23  sys.stdout.write('\n')
24  sys.stdout.flush()
25 
26 
def print_progress(iteration, total, decimals=1, bar_length=50)
Definition: convert.py:13

Variable Documentation

◆ args

convert.args = parser.parse_args()

Definition at line 54 of file convert.py.

◆ default

convert.default

Definition at line 53 of file convert.py.

◆ file_list

convert.file_list = list(ifilterfalse(is_not_h5m, args.file))

Definition at line 56 of file convert.py.

◆ help

convert.help

Definition at line 52 of file convert.py.

◆ int

convert.int

◆ N

convert.N = Value('i', len(file_list))

Definition at line 66 of file convert.py.

◆ n

convert.n = Value('i', 0)

Definition at line 67 of file convert.py.

◆ nargs

convert.nargs

Definition at line 52 of file convert.py.

◆ parser

convert.parser = argparse.ArgumentParser()

Definition at line 50 of file convert.py.

◆ pool

convert.pool = mp.Pool(args.np)

Definition at line 69 of file convert.py.

◆ type

convert.type