source: trunk/G2importphase_GPX.py @ 484

Last change on this file since 484 was 484, checked in by vondreele, 10 years ago

change authorship
split GSASIIelem into a GUI & non-GUI parts
replace MsgDialogs? in GSASIIElem.py with simple prints
cleanup & refactor distance/angle/torsion calcs.

File size: 1.9 KB
Line 
1########### SVN repository information ###################
2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
3# $Author: vondreele & toby $
4# $Revision: 482 $
5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase_GPX.py $
6# $Id: G2importphase_GPX.py 482 2012-02-13 17:33:35Z vondreele $
7########### SVN repository information ###################
8# Routines to import Phase information from GSAS-II .gpx files
9import cPickle
10import GSASIIIO as G2IO
11
12class PhaseReaderClass(G2IO.ImportPhase):
13    def __init__(self):
14        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
15            extensionlist=('.gpx',),
16            strictExtension=True,
17            formatName = 'GSAS-II gpx',
18            longFormatName = 'GSAS-II project (.gpx file) import'
19            )
20    def ContentsValidator(self, filepointer):
21        filepointer.seek(0) # rewind the file pointer
22        # if the 1st section can't be read as a cPickle file, it can't be!
23        try: 
24            cPickle.load(filepointer)
25        except:
26            return False
27        return True
28    def Reader(self,filename,filepointer, ParentFrame=None):
29        try:
30            phasenames = G2IO.GetPhaseNames(filename)
31            print phasenames
32        except:
33            return False
34        if not phasenames:
35            return False            # no blocks with coordinates
36        elif len(phasenames) == 1: # no choices
37            selblk = 0
38        else:                       # choose from options               
39            selblk = self.PhaseSelector(
40                phasenames,
41                ParentFrame=ParentFrame,
42                title= 'Select a phase from the list below',
43                )
44            if selblk is None: return False # User pressed cancel
45        try:
46            self.Phase = G2IO.GetAllPhaseData(filename,phasenames[selblk])
47            return True
48        except:
49            return False
50
Note: See TracBrowser for help on using the repository browser.