Ignore:
Timestamp:
Jun 23, 2016 9:25:06 PM (6 years ago)
Author:
toby
Message:

improve powder imports: suppress printing of binary data; improve validation of old GSAS binary files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2pwd_Pnn.py

    r2285 r2341  
    1616
    1717import sys
    18 import os.path as ospath
     18import os.path
    1919import numpy as np
    2020import array as ar
     
    2626    def __init__(self):
    2727        super(self.__class__,self).__init__( # fancy way to self-reference
    28             extensionlist=('.P*',),
     28            extensionlist=('.P01','.P02','.P03','.P04','.P05','.P06',
     29                           '.P07','.P08','.P09','.P*',),
    2930            strictExtension=False,
    30             formatName = 'GSAS Pnn',
    31             longFormatName = 'GSAS Pnn powder data file'
     31            formatName = 'GSAS .Pnn',
     32            longFormatName = 'GSAS .Pnn powder data file'
    3233            )
    3334
     
    3738        gotCcomment = False
    3839        self.GSAS = False
    39         return True # no errors encountered
     40        # file extension must be .Pxx or .pxx
     41        ext = os.path.splitext(filepointer.name)[1]
     42        if ext[1].upper() != 'P' or len(ext) != 4:
     43            return False
     44        if ext[2].isdigit() and ext[3].isdigit():
     45            return True # no errors encountered
     46        return False
     47       
    4048
    4149    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
     
    6472        self.powderentry[0] = filename
    6573        self.powderentry[2] = 1 # Pnn file only has one bank
    66         self.idstring = ospath.basename(filename)
     74        self.idstring = os.path.basename(filename)
    6775        return True
    6876     
Note: See TracChangeset for help on using the changeset viewer.