Changeset 54a8a01 in flex_extract.git for python/UioFiles.py


Ignore:
Timestamp:
Aug 31, 2018, 7:50:37 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
597d4d1
Parents:
e1228f3
Message:

restructuring, documentations and bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/UioFiles.py

    rff99eae r54a8a01  
    3434# @Class Content:
    3535#    - __init__
    36 #    - list_files
     36#    - __str__
     37#    - __list_files__
    3738#    - delete_files
    3839#
     
    5152# software specific module from flex_extract
    5253#import profiling
    53 from tools import silent_remove
     54from tools import silent_remove, get_list_as_string
    5455
    5556# ------------------------------------------------------------------------------
     
    6667    # CLASS FUNCTIONS
    6768    # --------------------------------------------------------------------------
    68     def __init__(self, pattern):
     69    def __init__(self, path, pattern):
    6970        '''
    7071        @Description:
     
    7576                Description see class documentation.
    7677
     78            path: string
     79                Directory where to list the files.
     80
    7781            pattern: string
    7882                Regular expression pattern. For example: '*.grb'
     
    8286        '''
    8387
     88        self.path = path
    8489        self.pattern = pattern
    8590        self.files = None
     91
     92        self.__list_files__(self.path)
    8693
    8794        return
    8895
    8996    #@profiling.timefn
    90     def list_files(self, path, callid=0):
     97    def __list_files__(self, path, callid=0):
    9198        '''
    9299        @Description:
     
    99106
    100107            path: string
    101                 Directory where to list the files.
     108                Path to the files.
    102109
    103110            callid: integer
     
    129136        if subdirs:
    130137            for subdir in subdirs:
    131                 self.list_files(os.path.join(path, subdir), callid=1)
     138                self.__list_files__(os.path.join(path, subdir), callid=1)
    132139
    133140        return
     141
     142    def __str__(self):
     143        '''
     144        @Description:
     145            Converts the list of files into a single string.
     146            The entries are sepereated by "," sign.
     147
     148        @Input:
     149            self: instance of UioFiles
     150                Description see class documentation.
     151
     152        @Return:
     153            files_string: string
     154                The content of the list as a single string.
     155        '''
     156
     157        filenames = [os.path.basename(f) for f in self.files]
     158        files_string = get_list_as_string(filenames, concatenate_sign=', ')
     159
     160        return files_string
    134161
    135162    def delete_files(self):
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG