diff --git a/larch/wxlib/cif_browser.py b/larch/wxlib/cif_browser.py index b8e4ddb51..76049f74e 100644 --- a/larch/wxlib/cif_browser.py +++ b/larch/wxlib/cif_browser.py @@ -26,7 +26,7 @@ from larch import Group from larch.xafs import feff8l, feff6l from larch.xrd.cif2feff import cif_sites -from larch.utils import read_textfile +from larch.utils import read_textfile, mkdir from larch.utils.paths import unixpath from larch.utils.strutils import fix_filename, unique_name, strict_ascii from larch.site_config import user_larchdir @@ -87,10 +87,8 @@ def __init__(self, parent=None, _larch=None, with_feff=False, if with_feff: self.larch.eval("if not hasattr('_sys', '_feffruns'): _sys._feffruns = {}") - path = unixpath(os.path.join(user_larchdir, 'feff')) - if not os.path.exists(path): - os.makedirs(path, mode=493) - self.feff_folder = path + self.feff_folder = unixpath(os.path.join(user_larchdir, 'feff')) + mkdir(self.feff_folder) self.feffruns_list = [] for fname in os.listdir(self.feff_folder): full = os.path.join(self.feff_folder, fname) @@ -539,14 +537,11 @@ def onRunFeff(self, event=None): fname = self.wids['feff_runfolder'].GetValue() fname = unique_name(fix_filename(fname), self.feffruns_list) self.feffruns_list.append(fname) - folder = unixpath(os.path.join(self.feff_folder, fname)) - - if not os.path.exists(folder): - os.makedirs(folder, mode=493) + self.folder = unixpath(os.path.join(self.feff_folder, fname)) + mkdir(self.folder) ix, p = self.get_nbpage('Feff Output') self.nb.SetSelection(ix) - self.folder = folder out = self.wids['feffout_text'] out.Clear() out.SetInsertionPoint(0) @@ -690,11 +685,8 @@ def onFeffFolder(self, eventa=None): dlg.SetPath(self.feff_folder) if dlg.ShowModal() == wx.ID_CANCEL: return None - path = os.path.abspath(dlg.GetPath()) - if not os.path.exists(path): - os.makedirs(path, mode=493) - self.feff_folder = path - + self.feff_folder = os.path.abspath(dlg.GetPath()) + mkdir(self.feff_folder) def onNBChanged(self, event=None): callback = getattr(self.nb.GetCurrentPage(), 'onPanelExposed', None) diff --git a/larch/wxlib/feff_browser.py b/larch/wxlib/feff_browser.py index 695b8578e..ad09c8bad 100644 --- a/larch/wxlib/feff_browser.py +++ b/larch/wxlib/feff_browser.py @@ -10,7 +10,7 @@ import larch from larch.site_config import user_larchdir -from larch.utils import unixpath, read_textfile +from larch.utils import unixpath, mkdir, read_textfile from larch.wxlib import (GridPanel, GUIColors, Button, pack, SimpleText, FileOpen, FileSave, Font, LEFT, FRAMESTYLE, FONTSIZE, MenuItem, EditableListBox, OkCancel, @@ -381,10 +381,8 @@ def __init__(self, parent=None, feffresult=None, path_importer=None, _larch=Non self.larch.symtable._sys._feffruns = {} self.parent = parent - path = unixpath(os.path.join(user_larchdir, 'feff')) - if not os.path.exists(path): - os.makedirs(path, mode=493) - self.feff_folder = path + self.feff_folder = unixpath(os.path.join(user_larchdir, 'feff')) + mkdir(self.feff_folder) self.SetTitle(title) self.SetSize((925, 650)) @@ -519,10 +517,8 @@ def onFeffFolder(self, event=None): dlg.SetPath(self.feff_folder) if dlg.ShowModal() == wx.ID_CANCEL: return None - path = os.path.abspath(dlg.GetPath()) - if not os.path.exists(path): - os.makedirs(path, mode=493) - self.feff_folder = path + self.feff_folder = os.path.abspath(dlg.GetPath()) + mkdir(self.feff_folder) def onImportFeffCalc(self, event=None): "prompt to import Feff calculation folder" diff --git a/larch/wxlib/plotter.py b/larch/wxlib/plotter.py index cec7b3701..b3f694c29 100644 --- a/larch/wxlib/plotter.py +++ b/larch/wxlib/plotter.py @@ -20,6 +20,7 @@ from wxmplot.interactive import get_wxapp import larch +from ..utils import mkdir from ..xrf import isLarchMCAGroup from ..larchlib import ensuremod from ..site_config import user_larchdir @@ -30,7 +31,7 @@ os.environ['MPLCONFIGDIR'] = mpl_dir if not os.path.exists(mpl_dir): try: - os.makedirs(mpl_dir) + mkdir(mpl_dir) except: pass