Skip to content

Commit

Permalink
use mkdir function
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Sep 26, 2023
1 parent 0bb02e4 commit e47486f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
22 changes: 7 additions & 15 deletions larch/wxlib/cif_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions larch/wxlib/feff_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion larch/wxlib/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e47486f

Please sign in to comment.