Skip to content

Commit d9775f0

Browse files
committed
minor cleanup; replacement GSASII/GSASII.py
1 parent 778d8ca commit d9775f0

File tree

6 files changed

+35
-902
lines changed

6 files changed

+35
-902
lines changed

GSASII/GSASII.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Starts GSAS-II from clone of GitHub repo when contents is not
2+
# installed into current Python.
3+
#
4+
# This can be used when GSAS-II is installed, but why bother as the command:
5+
# python -c "from GSASII.GSASIIGUI import main; main()"
6+
# will do just as well.
7+
import os
8+
import sys
9+
import importlib
10+
try:
11+
pkginfo = importlib.util.find_spec('GSASII.GSASIIGUI')
12+
except ModuleNotFoundError:
13+
pkginfo = None
14+
15+
if pkginfo is None: # fixup path if GSASII not installed into Python
16+
os.environ["GSASII_YOLO_PATH"] = "True"
17+
#print('GSAS-II not installed in Python: Hacking sys.path')
18+
sys.path.insert(0,os.path.dirname(os.path.dirname(__file__)))
19+
20+
from GSASII.GSASIIGUI import main
21+
22+
if __name__ == '__main__':
23+
if pkginfo is None: # fixup path if GSASII not installed into Python
24+
print('GSAS-II not installed in Python: Hacking sys.path')
25+
main()

GSASII/GSASIIphsGUI.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
import sys
2626
import random as ran
2727
import subprocess as subp
28+
import platform
29+
import shutil
2830

31+
import numpy as np
32+
import numpy.linalg as nl
33+
import numpy.ma as ma
2934
import scipy.optimize as so
3035
from . import GSASIIpath
3136
from . import GSASIIlattice as G2lat
@@ -49,13 +54,8 @@
4954
from . import GSASIIctrlGUI as G2G
5055
from . import GSASIIfiles as G2fl
5156
from . import GSASIIconstrGUI as G2cnstG
52-
import numpy as np
53-
import numpy.linalg as nl
54-
import numpy.ma as ma
5557
from . import atmdata
5658
from . import ISODISTORT as ISO
57-
import platform
58-
from ._utils import _copy_file
5959

6060
# XXX I suspect this is Unix-specific -- need porting help!
6161

@@ -6053,7 +6053,9 @@ def OnFileSel(event):
60536053
if os.path.exists(fName): # is there a file by this name in the current directory?
60546054
RMCPdict['files'][fil][0] = fName
60556055
else: # nope, copy it
6056-
_copy_file(dlg.GetPath(), os.path.join(G2frame.LastGPXdir,fName))
6056+
# TODO: is G2frame.LastGPXdir the right choice here or
6057+
# do I want the current working directory (same?)
6058+
shutil.copy(dlg.GetPath(), os.path.join(G2frame.LastGPXdir,fName))
60576059
if not os.path.exists(fName): # sanity check
60586060
print(f'Error: file {fName} not found in .gpx directory ({G2frame.LastGPXdir})')
60596061
return
@@ -7948,7 +7950,6 @@ def Runfullrmc(event):
79487950
finally:
79497951
dlg.Destroy()
79507952
if result == wx.ID_YES:
7951-
import shutil
79527953
shutil.rmtree(rmcname)
79537954
else:
79547955
return

GSASII/GSASIIstrIO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import time
1515
import math
1616
import random as rand
17+
import shutil
1718
import copy
1819
import pickle as cPickle
1920
import numpy as np
@@ -27,7 +28,6 @@
2728
from . import GSASIImath as G2mth
2829
from . import GSASIIstrMath as G2stMth
2930
from . import GSASIIfiles as G2fil
30-
from ._utils import _copy_file
3131

3232
sind = lambda x: np.sin(x*np.pi/180.)
3333
cosd = lambda x: np.cos(x*np.pi/180.)
@@ -632,7 +632,7 @@ def GPXBackup(GPXfile,makeBack=True):
632632
tries = 0
633633
while True:
634634
try:
635-
_copy_file(GPXfile,GPXback)
635+
shutil.copy(GPXfile,GPXback)
636636
break
637637
except:
638638
tries += 1

GSASII/_utils.py

Lines changed: 0 additions & 174 deletions
This file was deleted.

0 commit comments

Comments
 (0)