コード例 #1
0
 def complete(self, planspath, vehiclespath):
     complete = False
     if exists(planspath):
         complete = True
         log.info(f'Found file {planspath} already generated.')
     if exists(vehiclespath):
         complete = True
         log.info(f'Found file {vehiclespath} already generated.')
     return complete
コード例 #2
0
ファイル: events.py プロジェクト: ChesterIcarus/icarus-python
 def ready(self, eventspath, planspath):
     ready = True
     if not exists(planspath):
         log.warn(f'Could not find file {planspath} in run files.')
         ready = False
     if not exists(eventspath):
         log.warn(f'Could not find file {eventspath} in run files.')
         ready = False
     return ready
コード例 #3
0
ファイル: daymet.py プロジェクト: ruilee16/DataProcessing
 def ready(self, tmin_files, tmax_files):
     ready = True
     for netcdf_file in tmin_files + tmax_files:
         if not exists(netcdf_file):
             log.warn(f'Could not find file {netcdf_file}.')
             ready = False
     return ready
コード例 #4
0
def ready(trips_file: str, households_file: str, persons_file: str):
    ready = True
    abm_files = (trips_file, households_file, persons_file)
    for abm_file in abm_files:
        if not exists(trips_file):
            log.warn(f'Could not find file {abm_file}.')
            ready = False
    return ready
コード例 #5
0
ファイル: parcels.py プロジェクト: ruilee16/DataProcessing
 def ready(self, residence_file, commerce_file, parcel_file):
     ready = True
     tables = ('regions', )
     present = self.database.table_exists(*tables)
     if len(exists) < len(tables):
         missing = ', '.join(set(tables) - set(present))
         log.info(f'Could not find tables {missing} in database.')
         ready = False
     parcel_files = (residence_file, commerce_file, parcel_file)
     for parcel_file in parcel_files:
         if not exists(parcel_file):
             log.warn(f'Could not find file {parcel_file}.')
             ready = False
     return ready
コード例 #6
0
 def ready(self, network):
     ready = True
     schedule_files = ('agency.txt', 'calendar_dates.txt', 'calendar.txt',
                       'frequencies.txt', 'routes.txt', 'shapes.txt',
                       'stops.txt', 'stop_times.txt', 'transfers.txt',
                       'trips.txt')
     pathjoin = lambda x: os.path.join(network['roads']['schedule_dir'], x)
     schedule_files = tuple(map(pathjoin, schedule_files))
     network_files = (network['roads']['osm_file'],
                      network['roads']['osmosis'],
                      network['roads']['pt2matsim'], *schedule_files)
     for network_file in network_files:
         if not exists(network_file):
             log.warn(f'Could not find files {network_file}.')
             ready = False
     return ready
コード例 #7
0
ファイル: roads.py プロジェクト: ChesterIcarus/icarus-python
def ready(networkpath: str):
    present = exists(networkpath)
    if not present:
        log.info(f'Could not find file {networkpath}.')
    return present
コード例 #8
0
ファイル: config.py プロジェクト: ChesterIcarus/icarus-python
    def verify_param(self, name, spec, param):
        '''validates a single config parameter against a specification

        Parameters
        ----------
        name: str
            Name of the attribute being checked; used in error handling.

        spec: dict
            A dict containing the attributes of the parameter.

        param: int/float/str/bool
            The config parameter being validated.
        '''
        types = [self.types[t] for t in spec['type'].split(',')]

        if type(param) not in types:
            types = '", "'.join(spec['type'].split(','))
            log.error(f'Parameter "{name}" expected to be of type "'
                      f'{types}" but found "{type(param).__name__}".')
            raise TypeError

        if ('options' in spec and len(spec['options'])
                and param not in spec['options']):
            options = ', '.join([f'"{str(opt)}"' for opt in spec['options']])
            log.error(f'Parameter "{name}" expected to be {options} '
                      f'but found "{param}".')
            raise ValueError

        if 'exceptions' in spec and param in spec['exceptions']:
            log.error(f'Parameter "{name}" cannot be "{param}".')
            raise ValueError

        if 'min' in spec and param < spec['min']:
            log.error(f'Parameter "{name}" expected to be greater than '
                      f'{spec["min"]} but found {name}.')
            raise ValueError

        if 'max' in spec and param > spec['max']:
            log.error(f'Parameter "{name}" expected to be less than '
                      f'{spec["max"]} but found {param}.')
            raise ValueError

        if 'regex' in spec and not re.search(spec['regex'], param):
            log.error(f'Parameter "{name}" expected to match pattern '
                      f'{spec["regex"]} but found "{param}".')
            raise ValueError

        if 'file' in spec:
            if spec['file'] == 'exists' and not exists(param):
                log.error(
                    f'Parameter "{name}" expected to be an existing file '
                    'but file could not be found.')
                raise ValueError
            elif spec['file'] == 'readable' and not readable(param):
                log.error(
                    f'Parameter "{name}" expected to be an readable file '
                    'but file could not be read.')
                raise ValueError
            elif spec['file'] == 'writable' and not writable(param):
                log.error(
                    f'Parameter "{name}" expected to be an writable file '
                    'but file could not be written to.')
                raise ValueError