Changeset 3758 for trunk/imports/G2pwd_FP.py
- Timestamp:
- Dec 10, 2018 12:27:04 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/imports/G2pwd_FP.py
r3757 r3758 40 40 fp = open(filename,'r') 41 41 for i,S in enumerate(fp): 42 if i > 100: break42 if i > 50: break 43 43 if begin: 44 44 if gotCcomment and S.find('*/') > -1: … … 56 56 try: #look for start,step,stop card 57 57 for j,val in enumerate(vals): 58 num =float(val)58 float(val) 59 59 if j == 2: 60 60 break … … 84 84 for i,S in enumerate(fp): 85 85 self.errors = 'Error reading line: '+str(i+1) 86 # or a block of comments delimited by /* and */ 87 # or (GSAS style) each line can begin with '#' or '!' 86 # Allow a block of comments delimited by /* and */ 87 # or (GSAS style) each comment line can begin with '#' or '!' 88 if S.lstrip()[0] in ["'",'#','!',]: 89 self.comments.append(S[:-1]) 90 continue # store comments, if any 88 91 if begin: 89 92 if gotCcomment and S.find('*/') > -1: … … 95 98 gotCcomment = True 96 99 continue 97 if S.lstrip()[0] in ["'",'#','!',]: 98 self.comments.append(S[:-1]) 99 continue #ignore comments, if any 100 else: 101 begin = False 102 # valid line to read 100 # look for a line with start, steps etc. in 1st 4 lines 103 101 if not steps: 104 102 vals = S.replace(',',' ').split(None,4) … … 108 106 elif len(vals) >= 3: 109 107 try: 110 steps = True111 108 start = float(vals[0]) 112 109 step = float(vals[1]) 113 110 stop = float(vals[2]) 111 steps = True 112 begin = False 114 113 if len(vals) > 3: 115 114 self.comments.append(vals[3][:-1]) … … 120 119 print('Skipping header line ',S) 121 120 continue 121 # should be a valid line to read 122 122 vals = S.split() #data strings 123 123 try:
Note: See TracChangeset
for help on using the changeset viewer.