v0.13.2
Loading...
Searching...
No Matches
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)
 
def init (l)
 

Variables

 parser
 
 help
 
 nargs
 
 type
 
 int
 
 default
 
 SUPPRESS
 
 action
 
 args = parser.parse_args()
 
 file_list = list(filterfalse(is_not_h5m, args.file))
 
 N = mp.Value('i', len(file_list))
 
 n = mp.Value('i', 0)
 
 l = mp.Lock()
 
 pool = mp.Pool(processes=args.np, initializer=init, initargs=(l,))
 

Function Documentation

◆ init()

def convert.init (   l)

Definition at line 55 of file convert.py.

55def init(l):
56 global lock
57 lock = l
58

◆ is_not_h5m()

def convert.is_not_h5m (   file)

Definition at line 34 of file convert.py.

34def is_not_h5m(file):
35 return not file.endswith('h5m')
36

◆ is_older_than_vtk()

def convert.is_older_than_vtk (   file)

Definition at line 37 of file convert.py.

37def is_older_than_vtk(file):
38 file_vtk = path.splitext(file)[0] + ".vtk"
39 if path.exists(file_vtk):
40 return path.getmtime(file) < path.getmtime(file_vtk)
41 return False
42

◆ mb_convert()

def convert.mb_convert (   file)

Definition at line 43 of file convert.py.

43def mb_convert(file):
44 file = path.splitext(file)[0]
45 p = subprocess.Popen(["mbconvert", file + ".h5m", file + ".vtk"],
46 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
47 (out, err) = p.communicate()
48 lock.acquire()
49 if p.returncode:
50 print('\n' + err.decode())
51 n.value += 1
52 print_progress(n.value, N.value)
53 lock.release()
54

◆ print_progress()

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

Definition at line 24 of file convert.py.

24def print_progress(iteration, total, decimals=1, bar_length=50):
25 str_format = "{0:." + str(decimals) + "f}"
26 percents = str_format.format(100 * (iteration / float(total)))
27 filled_length = int(round(bar_length * iteration / float(total)))
28 bar = '█' * filled_length + '-' * (bar_length - filled_length)
29
30 sys.stdout.write('\r |%s| %s%s (%s of %s)' %
31 (bar, percents, '%', str(iteration), str(total)))
32 sys.stdout.flush()
33

Variable Documentation

◆ action

convert.action

Definition at line 65 of file convert.py.

◆ args

convert.args = parser.parse_args()

Definition at line 66 of file convert.py.

◆ default

convert.default

Definition at line 64 of file convert.py.

◆ file_list

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

Definition at line 71 of file convert.py.

◆ help

convert.help

Definition at line 63 of file convert.py.

◆ int

convert.int

Definition at line 64 of file convert.py.

◆ l

convert.l = mp.Lock()

Definition at line 84 of file convert.py.

◆ N

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

Definition at line 81 of file convert.py.

◆ n

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

Definition at line 82 of file convert.py.

◆ nargs

convert.nargs

Definition at line 63 of file convert.py.

◆ parser

convert.parser
Initial value:
1= argparse.ArgumentParser(
2 description="Convert multiple h5m files to vtk files using the mbconvert tool (part of the MOAB library). The input files can be distributed between multiple processes to speed-up the conversion.")

Definition at line 60 of file convert.py.

◆ pool

convert.pool = mp.Pool(processes=args.np, initializer=init, initargs=(l,))

Definition at line 85 of file convert.py.

◆ SUPPRESS

convert.SUPPRESS

Definition at line 65 of file convert.py.

◆ type

convert.type

Definition at line 64 of file convert.py.