quick prospector fixes for deprecated class
This commit is contained in:
parent
67f64b7a7a
commit
71da974bdc
|
@ -1,11 +1,10 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Section():
|
class Section():
|
||||||
def __init__(self,data = {'__order__':[]},part = ''):
|
def __init__(self,data = {'__order__':[]},part = ''):
|
||||||
|
"""New material.config section."""
|
||||||
classes = {
|
classes = {
|
||||||
'homogenization':Homogenization,
|
'homogenization':Homogenization,
|
||||||
'microstructure':Microstructure,
|
'microstructure':Microstructure,
|
||||||
|
@ -35,26 +34,31 @@ class Section():
|
||||||
|
|
||||||
class Homogenization(Section):
|
class Homogenization(Section):
|
||||||
def __init__(self,data = {'__order__':[]}):
|
def __init__(self,data = {'__order__':[]}):
|
||||||
|
"""New material.config <homogenization> section."""
|
||||||
Section.__init__(self,data)
|
Section.__init__(self,data)
|
||||||
|
|
||||||
|
|
||||||
class Crystallite(Section):
|
class Crystallite(Section):
|
||||||
def __init__(self,data = {'__order__':[]}):
|
def __init__(self,data = {'__order__':[]}):
|
||||||
|
"""New material.config <crystallite> section."""
|
||||||
Section.__init__(self,data)
|
Section.__init__(self,data)
|
||||||
|
|
||||||
|
|
||||||
class Phase(Section):
|
class Phase(Section):
|
||||||
def __init__(self,data = {'__order__':[]}):
|
def __init__(self,data = {'__order__':[]}):
|
||||||
|
"""New material.config <Phase> section."""
|
||||||
Section.__init__(self,data)
|
Section.__init__(self,data)
|
||||||
|
|
||||||
|
|
||||||
class Microstructure(Section):
|
class Microstructure(Section):
|
||||||
def __init__(self,data = {'__order__':[]}):
|
def __init__(self,data = {'__order__':[]}):
|
||||||
|
"""New material.config <microstructure> section."""
|
||||||
Section.__init__(self,data)
|
Section.__init__(self,data)
|
||||||
|
|
||||||
|
|
||||||
class Texture(Section):
|
class Texture(Section):
|
||||||
def __init__(self,data = {'__order__':[]}):
|
def __init__(self,data = {'__order__':[]}):
|
||||||
|
"""New material.config <texture> section."""
|
||||||
Section.__init__(self,data)
|
Section.__init__(self,data)
|
||||||
|
|
||||||
def add_component(self,theType,properties):
|
def add_component(self,theType,properties):
|
||||||
|
@ -79,10 +83,10 @@ class Texture(Section):
|
||||||
|
|
||||||
|
|
||||||
class Material():
|
class Material():
|
||||||
"""Reads, manipulates and writes material.config files"""
|
"""Read, manipulate, and write material.config files."""
|
||||||
|
|
||||||
def __init__(self,verbose=True):
|
def __init__(self,verbose=True):
|
||||||
"""Generates ordered list of parts"""
|
"""Generates ordered list of parts."""
|
||||||
self.parts = [
|
self.parts = [
|
||||||
'homogenization',
|
'homogenization',
|
||||||
'crystallite',
|
'crystallite',
|
||||||
|
@ -100,7 +104,7 @@ class Material():
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Returns current data structure in material.config format"""
|
"""Returns current data structure in material.config format."""
|
||||||
me = []
|
me = []
|
||||||
for part in self.parts:
|
for part in self.parts:
|
||||||
if self.verbose: print('processing <{}>'.format(part))
|
if self.verbose: print('processing <{}>'.format(part))
|
||||||
|
@ -158,9 +162,9 @@ class Material():
|
||||||
|
|
||||||
|
|
||||||
def read(self,filename=None):
|
def read(self,filename=None):
|
||||||
"""Reads material.config file"""
|
"""Read material.config file."""
|
||||||
def recursiveRead(filename):
|
def recursiveRead(filename):
|
||||||
"""Takes care of include statements like '{}'"""
|
"""Takes care of include statements like '{}'."""
|
||||||
result = []
|
result = []
|
||||||
re_include = re.compile(r'^{(.+)}$')
|
re_include = re.compile(r'^{(.+)}$')
|
||||||
with open(filename) as f: lines = f.readlines()
|
with open(filename) as f: lines = f.readlines()
|
||||||
|
@ -176,7 +180,7 @@ class Material():
|
||||||
self.parse(part=p, content=c)
|
self.parse(part=p, content=c)
|
||||||
|
|
||||||
def write(self,filename='material.config', overwrite=False):
|
def write(self,filename='material.config', overwrite=False):
|
||||||
"""Writes to material.config"""
|
"""Write to material.config."""
|
||||||
i = 0
|
i = 0
|
||||||
outname = filename
|
outname = filename
|
||||||
while os.path.exists(outname) and not overwrite:
|
while os.path.exists(outname) and not overwrite:
|
||||||
|
@ -189,7 +193,7 @@ class Material():
|
||||||
return outname
|
return outname
|
||||||
|
|
||||||
def add_section(self, part=None, section=None, initialData=None, merge=False):
|
def add_section(self, part=None, section=None, initialData=None, merge=False):
|
||||||
"""adding/updating"""
|
"""Add Update."""
|
||||||
part = part.lower()
|
part = part.lower()
|
||||||
section = section.lower()
|
section = section.lower()
|
||||||
if part not in self.parts: raise Exception('invalid part {}'.format(part))
|
if part not in self.parts: raise Exception('invalid part {}'.format(part))
|
||||||
|
|
Loading…
Reference in New Issue