Changeset 3356


Ignore:
Timestamp:
10/02/08 21:25:03 (12 years ago)
Author:
astephen
Message:

Fixed some bad imports in main na_file modules.

Location:
nappy/trunk/nappy
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/nappy/na_file/na_file_1010.py

    r3354 r3356  
    1717# Imports from local package 
    1818import nappy.utils.text_parser 
    19 import nappy.na_file.na_file.na_file_1001 
     19import nappy.na_file.na_file_1001 
    2020 
    2121class NAFile1010(nappy.na_file.na_file_1001.NAFile1001): 
  • nappy/trunk/nappy/na_file/na_file_1020.py

    r3349 r3356  
    1111""" 
    1212 
    13 # 08/05/04 updated by selatham for bug fixes 
    14 # 18/11/04 updated by selatham for new write method & bug fixes 
    15  
    1613# Imports from python standard library 
    1714 
     15 
    1816# Imports from local package 
    19 import utils.text_parser 
     17import nappy.utils.text_parser 
    2018import nappy.na_file.na_file_1010 
    2119 
     
    3230        self._normalized_X = False 
    3331        self._readCommonHeader() 
    34         self.DX = utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
     32        self.DX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
    3533        if self.DX == 0: 
    3634            raise "DX found to be zero (0). Not allowed for FFI 1020." 
    3735 
    38         self.NVPM = utils.text_parser.readItemFromLine(self.file.readline(), int) 
    39         self.XNAME = utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
     36        self.NVPM = nappy.utils.text_parser.readItemFromLine(self.file.readline(), int) 
     37        self.XNAME = nappy.utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
    4038        self._readVariablesHeaderSection() 
    4139        self._readAuxVariablesHeaderSection() 
     
    4846        # Now get the dependent variables 
    4947        raise "I need tidying up as my indentation is wrong! - 1020._readData2!" 
    50         (v, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.NV * self.NVPM, float)               
     48        (v, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.NV * self.NVPM, float)               
    5149        count = 0 
    5250        for n in range(self.NV): 
    5351            #self.V[n].append([]) 
    5452            for i in range(self.NVPM):   # Number of steps where independent variable is implied 
    55                 #self.V[n][ivar_count].append(v[count])                                          removed 
    56                 self.V[n].append(v[count])                                                               added 
     53                self.V[n].append(v[count])                                               
    5754                count = count + 1                                                                                
    5855        return rtlines 
  • nappy/trunk/nappy/na_file/na_file_2010.py

    r3349 r3356  
    1414 
    1515# Imports from local package 
    16 import utils.text_parser 
    17 import utils.list_manipulator 
     16import nappy.utils.text_parser 
     17import nappy.utils.list_manipulator 
    1818import nappy.na_file.na_file 
    1919 
     
    3131        self._normalized_X = False 
    3232        self._readCommonHeader() 
    33         self.DX = utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
     33        self.DX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
    3434        self.DX.reverse()  # Reverse because C-type array is least-changing first 
    35         self.NX = utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV - 1, int) 
     35        self.NX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV - 1, int) 
    3636        self.NX.reverse()  # Reverse because C-type array is least - changing first 
    37         self.NXDEF = utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV - 1, int) 
     37        self.NXDEF = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV - 1, int) 
    3838        self.NXDEF.reverse()  # Reverse because C-type array is least-changing first 
    3939        self.X = [] 
    4040        for i in range(self.NIV - 1): 
    41             self.X.append(utils.text_parser.readItemsFromUnknownLines(self.file, self.NXDEF[i], float)) 
     41            self.X.append(nappy.utils.text_parser.readItemsFromUnknownLines(self.file, self.NXDEF[i], float)) 
    4242        # Unbounded Independent variable should be first so insert empty list at start 
    43         self.X.reverse()                   # Bug fix - Ag Stephens - 21/06/05 
     43        self.X.reverse()                  
    4444        self.X.insert(0, []) 
    45         self.XNAME = utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
     45        self.XNAME = nappy.utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
    4646        self.XNAME.reverse()  # Reverse because C-type array is least-changing first 
    4747        self._readVariablesHeaderSection() 
     
    9999        """         
    100100        # Start with independent and Auxilliary vars 
    101         (x2_and_a, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, 1 + self.NAUXV, float) 
     101        print datalines 
     102        (x2_and_a, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, 1 + self.NAUXV, float) 
    102103        (x, aux) = (x2_and_a[0], x2_and_a[1:]) 
    103104        self.X[0].append(x) 
     
    114115        # Now get the dependent variables 
    115116        for n in range(self.NV): 
    116             (v, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.arraySize, float) 
     117            (v, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.arraySize, float) 
    117118            self.V[n].append([]) 
    118             utils.list_manipulator.recursiveListPopulator(self.V[n][ivar_count], v, self.NX) 
     119            nappy.utils.list_manipulator.recursiveListPopulator(self.V[n][ivar_count], v, self.NX) 
    119120            datalines = rtlines 
    120121        return rtlines 
     
    135136            # Write Variables 
    136137            for n in range(self.NV): 
    137                 outlines = utils.list_manipulator.recursiveListWriter(self.V[n][m], self.NX, spacer = self.spacer, float_format = self.float_format) 
     138                outlines = nappy.utils.list_manipulator.recursiveListWriter(self.V[n][m], self.NX, spacer = self.spacer, float_format = self.float_format) 
    138139                for line in outlines: 
    139140                    self.file.write(line) 
  • nappy/trunk/nappy/na_file/na_file_2110.py

    r3321 r3356  
    1414 
    1515# Imports from local package 
    16 import utils.text_parser 
     16import nappy.utils.text_parser 
    1717import nappy.na_file.na_file_2010 
    1818 
     
    2828        """ 
    2929        self._readCommonHeader() 
    30         self.DX = utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
     30        self.DX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), self.NIV, float) 
    3131        self.DX.reverse()  # Reverse because C-type array is least-changing first 
    32         self.XNAME = utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
     32        self.XNAME = nappy.utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
    3333        self.XNAME.reverse()  # Reverse because C-type array is least-changing first 
    3434        self._readVariablesHeaderSection() 
     
    7070        """     
    7171        # Start with independent and Auxilliary vars 
    72         (x_and_a, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.NAUXV + 1, float) 
     72        (x_and_a, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.NAUXV + 1, float) 
    7373        (x, aux) = (x_and_a[0], x_and_a[1:]) 
    7474        count = 0 
     
    9494 
    9595        for c in range(self.NX[ivar_count]): 
    96             (x_and_v, datalines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.NV + 1, float) 
     96            (x_and_v, datalines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.NV + 1, float) 
    9797            (x, v) = (x_and_v[0], x_and_v[1:]) 
    9898            self.X[ivar_count][1].append(x) 
  • nappy/trunk/nappy/na_file/na_file_2160.py

    r3349 r3356  
    1414 
    1515# Imports from local package 
    16 import utils.text_parser 
     16import nappy.utils.text_parser 
    1717import nappy.na_file.na_file_2110 
    1818 
     
    2929        self._normalized_X = False 
    3030        self._readCommonHeader() 
    31         self.DX = utils.text_parser.readItemsFromLine(self.file.readline(), 1, float) 
    32         self.LENX = utils.text_parser.readItemFromLine(self.file.readline(), float) 
    33         self.XNAME = utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
     31        self.DX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), 1, float) 
     32        self.LENX = nappy.utils.text_parser.readItemFromLine(self.file.readline(), float) 
     33        self.XNAME = nappy.utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
    3434        self.XNAME.reverse()  # Reverse because C-type array is least-changing first 
    3535        self._readVariablesHeaderSection() 
     
    8787        # Start with independent and Auxilliary vars 
    8888        # Get character string independent variable 
    89         (x1, datalines) = utils.text_parser.readItemsFromUnknownLines(datalines, 1, str) 
     89        (x1, datalines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, 1, str) 
    9090        self.X.append([]) 
    9191        self.X[ivar_count].append(x1[0]) 
     
    9494 
    9595        # Get NX and Non-character AUX vars 
    96         (aux, datalines) = utils.text_parser.readItemsFromUnknownLines(datalines, (self.NAUXV - self.NAUXC), float) 
     96        (aux, datalines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, (self.NAUXV - self.NAUXC), float) 
    9797        self.NX.append(int(aux[0])) 
    9898 
     
    103103 
    104104        # Get character AUX vars 
    105         (auxc) = utils.text_parser.readItemsFromLines(datalines[:self.NAUXC], self.NAUXC, str) 
     105        (auxc) = nappy.utils.text_parser.readItemsFromLines(datalines[:self.NAUXC], self.NAUXC, str) 
    106106        rtlines = datalines[self.NAUXC:] 
    107107        count = 0 
     
    135135            self.file.write("%s\n" % var_string.rstrip()) 
    136136 
    137              # Write second independant variable and dependant variables 
    138              for p in range(self.NX[m]): 
     137            # Write second independant variable and dependant variables 
     138            for p in range(self.NX[m]): 
    139139                var_string = "%s    " % self.X[m][1][p] 
    140140 
  • nappy/trunk/nappy/na_file/na_file_2310.py

    r3349 r3356  
    1414 
    1515# Imports from local package 
    16 import utils.text_parser 
     16import nappy.utils.text_parser 
    1717import nappy.na_file.na_file_2110 
    1818 
     
    2929        self._normalized_X = False 
    3030        self._readCommonHeader() 
    31         self.DX = utils.text_parser.readItemsFromLine(self.file.readline(), 1, float) 
    32         self.XNAME = utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
     31        self.DX = nappy.utils.text_parser.readItemsFromLine(self.file.readline(), 1, float) 
     32        self.XNAME = nappy.utils.text_parser.readItemsFromLines(self._readLines(self.NIV), self.NIV, str) 
    3333        self.XNAME.reverse()  # Reverse because C-type array is least-changing first           
    3434        self._readVariablesHeaderSection() 
     
    5656        """         
    5757        # Start with independent and Auxilliary vars 
    58         (x_and_a, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.NAUXV + 1, float) 
     58        (x_and_a, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.NAUXV + 1, float) 
    5959        (x, aux) = (x_and_a[0], x_and_a[1:]) 
    6060 
     
    7878        """ 
    7979        # Now get the dependent variables 
    80         (v, rtlines) = utils.text_parser.readItemsFromUnknownLines(datalines, self.NV * self.NX[ivar_count], float) 
     80        (v, rtlines) = nappy.utils.text_parser.readItemsFromUnknownLines(datalines, self.NV * self.NX[ivar_count], float) 
    8181        count = 0 
    8282        for n in range(self.NV): 
  • nappy/trunk/nappy/na_file/na_file_3010.py

    r3321 r3356  
    1414 
    1515# Imports from local package 
    16 import utils.text_parser 
     16import nappy.utils.text_parser 
    1717import nappy.na_file.na_file_2010 
    1818 
  • nappy/trunk/nappy/utils/text_parser.py

    r3321 r3356  
    5656    also returned. 
    5757    """ 
     58 
     59    """ 
    5860    rtitems = [] 
    5961    lines = []         
     
    8486    else: 
    8587        return rtitems 
     88""" 
    8689 
     90    rtitems=[] 
     91    lines=[] 
     92    if type(object) is list: 
     93        nextitem=object[0] 
     94        del object[0] 
     95        while len(rtitems)<nitems: 
     96            #items=re.split(r"\s+", nextitem.strip()) 
     97            items=nextitem.strip().split() 
     98            lines.append(items) 
     99            (rtitems,extras)=(rtitems+items[:nitems],items[nitems:]) 
     100        if len(extras)>0: 
     101            raise "Could not split %s lines exactly into required number (%s) of items: \n%s" % (len(lines), nitems, lines) 
     102        if rttype is not str: 
     103            rtitems = [rttype(x) for x in rtitems] 
     104        return (rtitems, object) 
     105    else: 
     106        lines =[] 
     107        while len(rtitems)<nitems: 
     108            #items=re.split(r"\s+", object.readline().strip()) 
     109            items=object.readline().strip().split() 
     110            lines.append(items) 
     111            (rtitems,extras)=(rtitems+items[:nitems], items[nitems:]) 
     112        if len(extras)>0: 
     113            raise "Could not split %s lines exactly into required number (%s) of items: \n%s" % (len(lines), nitems, lines) 
     114        if rttype is not str: 
     115            rtitems = [rttype(x) for x in rtitems] 
     116        return rtitems 
    87117 
    88  
    89  
    90      
    91      
    92  
Note: See TracChangeset for help on using the changeset viewer.