if comptype == 'gz' or comptype == 'bz2':
kwargs['compresslevel'] = compresslevel
- if 'max_volume_size' in kwargs or 'new_volume_handler' in kwargs:
- if comptype != 'tar' and (kwargs['new_volume_handler'] or
- kwargs['max_volume_size']):
- import warnings
- warnings.warn('Only the first volume will be compressed '
- 'for modes with "w:"!')
+ is_multivol = False
+ if filemode in 'wa' and 'max_volume_size' in kwargs \
+ and kwargs['max_volume_size'] \
+ and 'new_volume_handler' in kwargs \
+ and kwargs['new_volume_handler']:
+ is_multivol = True
+ if filemode == 'r' and 'new_volume_handler' in kwargs \
+ and kwargs['new_volume_handler']:
+ is_multivol = True # may be multi-volume
+ if is_multivol and comptype != 'tar':
+ import warnings
+ warnings.warn('Only the first volume will be compressed '
+ 'for modes with "w:"!')
return func(name, filemode, fileobj, **kwargs)