Changeset 5127
- Timestamp:
- Jan 7, 2022 3:17:14 PM (21 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r5099 r5127 1554 1554 self.SeqRefdata = None 1555 1555 self.SeqRefhist = None 1556 self.DelayOpen = False 1556 1557 if self.G2frame.GPXtree.IsEmpty(): return # nothing to do 1557 1558 histType = None … … 1770 1771 return 1771 1772 if self.fp is None: 1772 raise Exception('Attempt to CloseFile without use of OpenFile') 1773 if GSASIIpath.GetConfigValue('debug'): 1774 raise Exception('Attempt to CloseFile without use of OpenFile') 1775 else: 1776 print('Attempt to CloseFile without use of OpenFile') 1777 return 1773 1778 if self.fp == sys.stdout: return # debug mode 1774 1779 if fp is None: -
trunk/exports/G2export_CIF.py
r5115 r5127 4519 4519 4520 4520 WriteCIFitem(self.fp, '#--' + 15*'eof--' + '#') 4521 print("...export completed") 4522 print('file '+self.fullpath) 4521 print("...export completed. File created:",self.fullpath) 4523 4522 # end of CIF export 4524 4523 … … 4541 4540 self.Controls = Controls 4542 4541 self.InitExport(event) 4542 self.CIFname = '' 4543 4543 # load all of the tree into a set of dicts 4544 4544 self.loadTree() … … 5171 5171 defaultname='', cifKey="CIF_template"): 5172 5172 def _onResetTemplate(event): 5173 self.CIF = None5174 self.dict[self.cifKey] = resetTemplate5173 self.CIF_template = resetTemplate 5174 self.dict[self.cifKey] = None 5175 5175 wx.CallAfter(self.repaint) 5176 5176 wx.BoxSizer.__init__(self,wx.VERTICAL) … … 5213 5213 localTemplate = fil 5214 5214 break 5215 5216 if G2dict.get(self.cifKey) == localTemplate and localTemplate: 5217 self.CIF = localTemplate 5218 CIFtxt = "Customized template: "+os.path.split(self.CIF)[1] 5219 elif G2dict.get(self.cifKey) == resetTemplate and resetTemplate: 5220 self.CIF = resetTemplate 5221 CIFtxt = "Default template: "+os.path.split(self.CIF)[1] 5222 elif not G2dict.get(self.cifKey): # empty or None 5223 if localTemplate: 5224 G2dict[self.cifKey] = self.CIF = localTemplate 5225 CIFtxt = "Customized template: "+os.path.split(self.CIF)[1] 5226 elif resetTemplate: 5227 G2dict[self.cifKey] = self.CIF = resetTemplate 5228 CIFtxt = "Default template: "+os.path.split(self.CIF)[1] 5215 repeat = True 5216 while repeat: 5217 repeat = False 5218 if G2dict.get(self.cifKey) == localTemplate and localTemplate: 5219 self.CIF_template = localTemplate 5220 CIFtxt = "Customized template: "+os.path.split(self.CIF_template)[1] 5221 elif resetTemplate and G2dict.get(self.cifKey) == resetTemplate: 5222 self.CIF_template = resetTemplate 5223 CIFtxt = "Default template: "+os.path.split(self.CIF_template)[1] 5224 elif not G2dict.get(self.cifKey): # empty or None 5225 if localTemplate: 5226 G2dict[self.cifKey] = self.CIF_template = localTemplate 5227 CIFtxt = "Customized template: "+os.path.split(self.CIF_template)[1] 5228 elif resetTemplate: 5229 G2dict[self.cifKey] = None 5230 self.CIF_template = resetTemplate 5231 CIFtxt = "Default template: "+os.path.split(self.CIF_template)[1] 5232 else: 5233 G2dict[self.cifKey] = self.CIF_template = None 5234 CIFtxt = "none (Template not found!)" 5235 elif type(G2dict[self.cifKey]) is not list and type( 5236 G2dict[self.cifKey]) is not tuple: 5237 if not os.path.exists(G2dict[self.cifKey]): 5238 print("\nWarning: previous template file:\n ", 5239 os.path.abspath(G2dict[self.cifKey]), 5240 '\nwas not found! Was this file moved or deleted? Resetting to default.') 5241 self.CIF_template = None 5242 CIFtxt = "none! (file not found)" 5243 if resetTemplate: 5244 G2dict[self.cifKey] = None 5245 repeat = True 5246 continue 5247 else: 5248 CIFtxt = "Edited template: "+os.path.split(G2dict[self.cifKey])[1] 5249 if GSASIIpath.GetConfigValue('debug'): 5250 print('Template file found',os.path.abspath(G2dict[self.cifKey])) 5229 5251 else: 5230 G2dict[self.cifKey] = self.CIF = None 5231 CIFtxt = "none (Template not found!)" 5232 elif type(G2dict[self.cifKey]) is not list and type( 5233 G2dict[self.cifKey]) is not tuple: 5234 if not os.path.exists(G2dict[self.cifKey]): 5235 print("Warning: saved template file,", 5236 os.path.abspath(G2dict[self.cifKey]), 5237 ' not found!\nWas this file moved or deleted?') 5238 self.CIF = None 5239 CIFtxt = "none! (file not found)" 5240 if resetTemplate: 5241 G2dict[self.cifKey] = None 5242 wx.CallLater(100,self.repaint) 5243 return 5244 else: 5245 CIFtxt = "Edited template: "+os.path.split(G2dict[self.cifKey])[1] 5246 if GSASIIpath.GetConfigValue('debug'): 5247 print('Template file found',os.path.abspath(G2dict[self.cifKey])) 5248 else: 5249 self.CIF = G2dict[self.cifKey] 5250 CIFtxt = "Customized template is reloaded" 5252 self.CIF_template = G2dict[self.cifKey] 5253 CIFtxt = "Customized template is reloaded" 5251 5254 # show template source 5252 5255 self.Add(wx.StaticText(panel,wx.ID_ANY,CIFtxt)) … … 5258 5261 but = wx.Button(panel,wx.ID_ANY,"Edit Template") 5259 5262 but.Bind(wx.EVT_BUTTON,self._onEditTemplateContents) 5260 if self.CIF is None: but.Disable() # nothing to edit!5263 if self.CIF_template is None: but.Disable() # nothing to edit! 5261 5264 if resetTemplate and not CIFtxt.startswith('Default'): 5262 5265 hbox.Add(but,0,0,2) … … 5289 5292 def _onEditTemplateContents(self,event): 5290 5293 'Called to edit the contents of a CIF template' 5291 if type(self.CIF ) is list or type(self.CIF) is tuple:5292 dblk,loopstructure = copy.deepcopy(self.CIF ) # don't modify original5294 if type(self.CIF_template) is list or type(self.CIF_template) is tuple: 5295 dblk,loopstructure = copy.deepcopy(self.CIF_template) # don't modify original 5293 5296 else: 5294 cf = G2obj.ReadCIF(self.CIF )5297 cf = G2obj.ReadCIF(self.CIF_template) 5295 5298 dblk,loopstructure = CIF2dict(cf) 5296 5299 dlg = EditCIFtemplate(self.cifdefs,dblk,loopstructure,self.defaultname)
Note: See TracChangeset
for help on using the changeset viewer.