Changeset 1074 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Oct 2, 2013 9:27:17 AM (8 years ago)
Author:
toby
Message:

more CIF work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r1057 r1074  
    19001900        self.numbanks = 1
    19011901        self.instdict = {} # place items here that will be transferred to the instrument parameters
     1902######################################################################
     1903def ReadCIF(URLorFile):
     1904    '''Open a CIF, which may be specified as a file name or as a URL using PyCifRW
     1905    (from James Hester).
     1906    The open routine gets confused with DOS names that begin with a letter and colon
     1907    "C:\dir\" so this routine will try to open the passed name as a file and if that
     1908    fails, try it as a URL
     1909
     1910    :param str URLorFile: string containing a URL or a file name. Code will try first
     1911      to open it as a file and then as a URL.
     1912
     1913    :returns: a PyCifRW CIF object.
     1914    '''
     1915    import CifFile as cif # PyCifRW from James Hester
     1916
     1917    # alternate approach:
     1918    #import urllib
     1919    #ciffile = 'file:'+urllib.pathname2url(filename)
     1920   
     1921    try:
     1922        fp = open(URLorFile,'r')
     1923        cf = cif.ReadCif(fp)
     1924        fp.close()
     1925        return cf
     1926    except IOError:
     1927        return cif.ReadCif(URLorFile)
    19021928
    19031929if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.