Changeset ff99eae in flex_extract.git for python/ControlFile.py


Ignore:
Timestamp:
Jun 1, 2018, 8:34:59 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
e1228f3
Parents:
ccab809
Message:

completed application of pep8 style guide and pylint investigations. added documentation almost everywhere

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ControlFile.py

    r812283d rff99eae  
    22# -*- coding: utf-8 -*-
    33#************************************************************************
    4 # TODO AP
     4# ToDo AP
    55# - write a test class
    66#************************************************************************
     
    3737#    - __init__
    3838#    - __str__
    39 #    - tolist
     39#    - to_list
     40#
     41# @Class Attributes:
     42#    - start_date
     43#    - end_date
     44#    - accuracy
     45#    - omega
     46#    - cwc
     47#    - omegadiff
     48#    - etadiff
     49#    - level
     50#    - levelist
     51#    - step
     52#    - maxstep
     53#    - prefix
     54#    - makefile
     55#    - basetime
     56#    - date_chunk
     57#    - grib2flexpart
     58#    - exedir
     59#    - flexpart_root_scripts
     60#    - ecmwfdatadir
    4061#
    4162#*******************************************************************************
     
    4667import os
    4768import inspect
     69
    4870# software specific module from flex_extract
    49 import Tools
     71from tools import get_list_as_string, my_error
    5072
    5173# ------------------------------------------------------------------------------
    5274# CLASS
    5375# ------------------------------------------------------------------------------
    54 class ControlFile:
     76class ControlFile(object):
    5577    '''
    5678    Class containing the information of the flex_extract CONTROL file.
     
    114136                        for d in dd:
    115137                            data.append(d)
    116                     pass
    117138                if len(data) == 2:
    118139                    if '$' in data[1]:
     
    126147                                data[1] = data[1][:i] + var + data[1][k+1:]
    127148                            else:
    128                                 Tools.myerror(None,
    129                                               'Could not find variable ' +
    130                                               data[1][j+1:k] +
    131                                               ' while reading ' +
    132                                               filename)
     149                                my_error(None, 'Could not find variable ' +
     150                                         data[1][j+1:k] + ' while reading ' +
     151                                         filename)
    133152                        setattr(self, data[0].lower() + '_expanded', data[1])
    134153                    else:
     
    160179        if not hasattr(self, 'levelist'):
    161180            if not hasattr(self, 'level'):
    162                 print('Warning: neither levelist nor level \
    163                        specified in CONTROL file')
     181                print 'Warning: neither levelist nor level \
     182                       specified in CONTROL file'
    164183            else:
    165184                self.levelist = '1/to/' + self.level
     
    224243        return ', '.join("%s: %s" % item for item in attrs.items())
    225244
    226     def tolist(self):
     245    def to_list(self):
    227246        '''
    228247        @Description:
     
    255274                pass
    256275            else:
    257                 if type(item[1]) is list:
     276                if isinstance(item[1], list):
    258277                    stot = ''
    259278                    for s in item[1]:
     
    265284
    266285        return sorted(l)
     286
     287    # def to_dict(self):
     288        # '''
     289
     290        # '''
     291        # parameters_dict = vars(self)
     292
     293        # # remove unneeded parameter
     294        # parameters_dict.pop('_expanded', None)
     295        # parameters_dict.pop('exedir', None)
     296        # parameters_dict.pop('flexpart_root_scripts', None)
     297        # parameters_dict.pop('ecmwfdatadir', None)
     298
     299        # parameters_dict_str = {}
     300        # for key, value in parameters_dict.iteritems():
     301            # if isinstance(value, list):
     302                # parameters_dict_str[str(key)] = get_list_as_string(value, ' ')
     303            # else:
     304                # parameters_dict_str[str(key)] = str(value)
     305
     306        # return parameters_dict_str
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG