Changeset 4635 for trunk


Ignore:
Timestamp:
Nov 1, 2020 11:11:13 AM (3 years ago)
Author:
vondreele
Message:

change all 'Ur' to 'r' in open commands
double all '\' in G2scriptable
close dangling open files

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r4619 r4635  
    116116    asind = lambda x: 180.*math.asin(x)/math.pi
    117117    wave = 1.54052
    118     File = open(fileName,'Ur')
     118    File = open(fileName,'r')
    119119    Comments = []
    120120    peaks = []
  • trunk/GSASIIconstrGUI.py

    r4624 r4635  
    18201820            if dlg.ShowModal() == wx.ID_OK:
    18211821                macfile = dlg.GetPath()
    1822                 macro = open(macfile,'Ur')
     1822                macro = open(macfile,'r')
    18231823                head = macro.readline()
    18241824                if macName not in head:
     
    18411841                txtfile = dlg.GetPath()
    18421842                ext = os.path.splitext(txtfile)[1]
    1843                 text = open(txtfile,'Ur')
     1843                text = open(txtfile,'r')
    18441844            else: # cancel was pressed
    18451845                ext = ''
     
    25832583        filename = filelist[0]
    25842584        rd = reader
    2585         with open(filename, 'Ur'):
     2585        with open(filename, 'r'):
    25862586            rd.ReInitialize()
    25872587            rd.errors = ""
  • trunk/GSASIIdataGUI.py

    r4628 r4635  
    694694        except UnicodeDecodeError:
    695695            rdmsg = None
     696        fp.close()
    696697        if rdmsg is None or not all([ord(c) < 128 and ord(c) != 0 for c in rdmsg]): # show only if ASCII
    697698            rdmsg = u'File '+ filename +u' is a binary file. Do you want to read this file?'
     
    14641465        fp = 0
    14651466        try:
    1466             fp = open(instfile,'Ur')
     1467            fp = open(instfile,'r')
    14671468            Iparm = {}
    14681469            for S in fp:
  • trunk/GSASIIfiles.py

    r4594 r4635  
    644644            G2Print('Read '+lblFil)
    645645        # scan through each line in this .par file, looking for the matching image rootname
    646         fp = open(parFil,'Ur')
     646        fp = open(parFil,'r')
    647647        for iline,line in enumerate(fp):
    648648            items = line.strip().split(' ')
     
    680680    labels = {}
    681681    errors = []
    682     fp = open(lblFil,'Ur')         # read column labels
     682    fp = open(lblFil,'r')         # read column labels
    683683    for iline,line in enumerate(fp): # read label definitions
    684684        line = line.strip()
  • trunk/GSASIIimgGUI.py

    r4619 r4635  
    40154015        imageName = os.path.splitext(os.path.split(fileorline)[1])[0]
    40164016
    4017     fp = open(parFile,'Ur')
     4017    fp = open(parFile,'r')
    40184018    for iline,line in enumerate(fp):
    40194019        if linenum is not None:
  • trunk/GSASIIrestrGUI.py

    r4594 r4635  
    8080            if dlg.ShowModal() == wx.ID_OK:
    8181                macfile = dlg.GetPath()
    82                 macro = open(macfile,'Ur')
     82                macro = open(macfile,'r')
    8383                head = macro.readline()
    8484                if macName not in head:
     
    9898            if dlg.ShowModal() == wx.ID_OK:
    9999                csvfile = dlg.GetPath()
    100                 mogul = open(csvfile,'Ur')
     100                mogul = open(csvfile,'r')
    101101                head = mogul.readline()
    102102                if 'Type' not in head:
  • trunk/GSASIIscriptable.py

    r4607 r4635  
    472472                                            be either a dictionary of 'low' and/or 'high',
    473473                                            or a list of 2 items [low, high]
    474 \                     low                   Sets the low limit
    475 \                     high                  Sets the high limit
     474\\                    low                   Sets the low limit
     475\\                    high                  Sets the high limit
    476476
    477477Sample Parameters                           Should be provided as a **list** of subkeys
    478                                             to set or clear, e.g. ['DisplaceX', 'Scale']
    479 \                     Absorption
    480 \                     Contrast
    481 \                     DisplaceX             Sample displacement along the X direction
    482 \                     DisplaceY             Sample displacement along the Y direction
    483 \                     Scale                 Histogram Scale factor
     478                                            to set or clear,\\e.g. ['DisplaceX', 'Scale']
     479\\                    Absorption
     480\\                    Contrast
     481\\                    DisplaceX             Sample displacement along the X direction
     482\\                    DisplaceY             Sample displacement along the Y direction
     483\\                    Scale                 Histogram Scale factor
    484484
    485485Background                                  Sample background. Value will be a dict or
     
    491491                                            When value is a dict,
    492492                                            supply any of the following keys:
    493 \                     type                  The background model, e.g. 'chebyschev-1'
    494 \                     refine                The value of the refine flag, boolean
    495 \                     'no. coeffs'          Number of coefficients to use, integer
    496 \                     coeffs                List of floats, literal values for background
    497 \                     FixedPoints           List of (2-theta, intensity) values for fixed points
    498 \                     'fit fixed points'    If True, triggers a fit to the fixed points to
     493\\                    type                  The background model, e.g. 'chebyschev-1'
     494\\                    refine                The value of the refine flag, boolean
     495\\                    'no. coeffs'          Number of coefficients to use, integer
     496\\                    coeffs                List of floats, literal values for background
     497\\                    FixedPoints           List of (2-theta, intensity) values for fixed points
     498\\                    'fit fixed points'    If True, triggers a fit to the fixed points to
    499499                                            be calculated. It is calculated when this key is
    500500                                            detected, regardless of calls to refine.
    501 \                     peaks                 Specifies a set of flags for refining
     501\\                    peaks                 Specifies a set of flags for refining
    502502                                            background peaks as a nested list. There may
    503503                                            be an item for each defined background peak
     
    509509                                            subkeys to
    510510                                            set or clear, e.g. ['X', 'Y', 'Zero', 'SH/L']
    511 \                     U, V, W               Gaussian peak profile terms
    512 \                     X, Y, Z               Lorentzian peak profile terms
    513 \                     alpha, beta-0,        TOF profile terms
     511\\                    U, V, W               Gaussian peak profile terms
     512\\                    X, Y, Z               Lorentzian peak profile terms
     513\\                    alpha, beta-0,        TOF profile terms
    514514                      beta-1, beta-q,
    515 \                     sig-0, sig-1,         TOF profile terms
     515\\                    sig-0, sig-1,         TOF profile terms
    516516                      sig-2, sig-q
    517 \                     difA, difB, difC      TOF Calibration constants
    518 \                     Zero                  Zero shift
    519 \                     SH/L                  Finger-Cox-Jephcoat low-angle peak asymmetry
    520 \                     Polariz.              Polarization parameter
    521 \                     Lam                   Lambda, the incident wavelength
     517\\                    difA, difB, difC      TOF Calibration constants
     518\\                    Zero                  Zero shift
     519\\                    SH/L                  Finger-Cox-Jephcoat low-angle peak asymmetry
     520\\                    Polariz.              Polarization parameter
     521\\                    Lam                   Lambda, the incident wavelength
    522522===================== ====================  =================================================
    523523
     
    572572                                       subkeys. If not, assumes both
    573573                                       BabA and BabU
    574 \               BabA
    575 \               BabU
     574\\              BabA
     575\\              BabU
    576576Extinction                             Boolean, True to refine.
    577577HStrain                                Boolean or list/tuple, True to refine all
    578                                        appropriate D\ :sub:`ij` terms or False
     578                                       appropriate D\\ :sub:`ij` terms or False
    579579                                       to not refine any. If a list/tuple, will
    580580                                       be a set of True & False values for each
    581                                        D\ :sub:`ij` term; number of items must
     581                                       D\\ :sub:`ij` term; number of items must
    582582                                       match number of terms.
    583583Mustrain
    584 \               type                   Mustrain model. One of 'isotropic',
     584\\              type                   Mustrain model. One of 'isotropic',
    585585                                       'uniaxial', or 'generalized'. **Should always
    586586                                       be included when Mustrain is used.**
    587 \              direction               For uniaxial only. A list of three
     587\\              direction              For uniaxial only. A list of three
    588588                                       integers,
    589589                                       the [hkl] direction of the axis.
    590 \               refine                 Usually boolean, set to True to refine.
     590\\              refine                 Usually boolean, set to True to refine.
    591591                                       or False to clear.
    592592                                       For uniaxial model, can specify a value
     
    595595                                       boolean sets both axial and equatorial.
    596596Size                                   
    597 \               type                   Size broadening model. One of 'isotropic',
     597\\              type                   Size broadening model. One of 'isotropic',
    598598                                       'uniaxial', or 'ellipsoid'. **Should always
    599599                                       be specified when Size is used.**
    600 \              direction               For uniaxial only. A list of three
     600\\              direction              For uniaxial only. A list of three
    601601                                       integers,
    602602                                       the [hkl] direction of the axis.
    603 \               refine                 Boolean, True to refine.
    604 \               value                  float, size value in microns
     603\\              refine                 Boolean, True to refine.
     604\\              value                  float, size value in microns
    605605Pref.Ori.                              Boolean, True to refine
    606606Show                                   Boolean, True to refine
     
    718718in Windows::
    719719
    720     Z:\>fc before.txt after.txt
     720    Z:\\>fc before.txt after.txt
    721721    Comparing files before.txt and after.txt
    722722    ***** before.txt
     
    11861186import argparse
    11871187import os.path as ospath
    1188 import datetime as dt
     1188#import datetime as dt
    11891189import sys
    11901190import platform
     
    11951195    import pickle as cPickle
    11961196    strtypes = (str,bytes)
    1197 import imp
     1197#import imp
    11981198import copy
    11991199import os
     
    16901690        raise G2ImportException("Could not read file: ", filename)
    16911691
    1692     with open(filename, 'Ur') as fp:
     1692    with open(filename, 'r'):
    16931693        rd_list = []
    16941694
     
    17681768    # It's an old GSAS file, load appropriately
    17691769    Iparm = {}
    1770     with open(instfile, 'Ur') as fp:
     1770    with open(instfile, 'r') as fp:
    17711771        for line in fp:
    17721772            if '#' in line:
     
    40764076                for o in obj:
    40774077                    print('\t',o.formatName)
    4078                 raise G2ScriptException('Bad format hint for file type = "'+exten+'"')
     4078                raise G2ScriptException('Bad format hint for file type = "'+extension+'"')
    40794079        self._SetFromArray(obj)
    40804080        obj.Writer(self.name,fil)
     
    47944794        from exports import G2export_CIF as cif
    47954795
    4796         CIFdate = dt.datetime.strftime(dt.datetime.now(),"%Y-%m-%dT%H:%M")
     4796#        CIFdate = dt.datetime.strftime(dt.datetime.now(),"%Y-%m-%dT%H:%M")
    47974797        CIFname = os.path.splitext(self.proj.filename)[0]
    47984798        CIFname = os.path.split(CIFname)[1]
    47994799        CIFname = ''.join([c if ord(c) < 128 else ''
    48004800                           for c in CIFname.replace(' ', '_')])
    4801         try:
    4802             author = self.proj['Controls']['data'].get('Author','').strip()
    4803         except KeyError:
    4804             pass
    4805         oneblock = True
     4801        # try:
     4802        #     author = self.proj['Controls']['data'].get('Author','').strip()
     4803        # except KeyError:
     4804        #     pass
     4805        # oneblock = True
    48064806
    48074807        covDict = self.proj['Covariance']['data']
     
    52365236        :param str parmType: should be 'size' or 'microstrain' (can be abbreviated to 's' or 'm')
    52375237        :param str mode: should be 'isotropic' or 'uniaxial' (can be abbreviated to 'i' or 'u')
    5238         :param float val1: value for isotropic size (in :math:`\mu m`) or 
    5239            microstrain (unitless, :math:`\Delta Q/Q \\times 10^6`) or the equatorial value in the uniaxial case
    5240         :param float val2: value for axial size (in :math:`\mu m`) or 
    5241            axial microstrain (unitless, :math:`\Delta Q/Q \\times 10^6`)
     5238        :param float val1: value for isotropic size (in :math:`\\mu m`) or 
     5239           microstrain (unitless, :math:`\\Delta Q/Q \\times 10^6`) or the equatorial value in the uniaxial case
     5240        :param float val2: value for axial size (in :math:`\\mu m`) or 
     5241           axial microstrain (unitless, :math:`\\Delta Q/Q \\times 10^6`)
    52425242           in uniaxial case; not used for isotropic
    52435243        :param list axis: tuple or list with three values indicating the preferred direction
     
    53285328            if item in list(copydict.keys()):
    53295329                del copydict[item]
    5330             else:
    5331                 G2fil.G2Print('items in HAP dict are: {}'.format(
    5332                     list(self.data['Histograms'][sourcehist])))
    5333                 raise Exception('HAP skip list entry {} invalid'.format(item))
     5330            # else:
     5331            #     G2fil.G2Print('items in HAP dict are: {}'.format(
     5332            #         list(self.data['Histograms'][sourcehist])))
     5333            #     raise Exception('HAP skip list entry {} invalid'.format(item))
    53345334        if use:
    53355335            for item in list(copydict.keys()):
     
    68816881            d = d[k]
    68826882        l = []
    6883         first = True
     6883#        first = True
    68846884    if type(d) is dict:
    68856885        [dictDive(d[key],search,keylist+[key],False,l) for key in d]
  • trunk/imports/G2phase_CIF.py

    r4476 r4635  
    5252    def ContentsValidator(self, filename):
    5353        fp = open(filename,'r')
    54         return self.CIFValidator(fp)
     54        ok = self.CIFValidator(fp)
    5555        fp.close()
     56        return ok
    5657
    5758    def Reader(self,filename, ParentFrame=None, usedRanIdList=[], **unused):
Note: See TracChangeset for help on using the changeset viewer.