@@ -73,7 +73,7 @@ def read_dispatcher(
7373
7474
7575def write_dispatcher (
76- source : list [dict ], fmt : str , outfile : Union [None , str ]
76+ source : list [dict ], fmt : str , outfile : Union [None , str ], bz2 : bool ,
7777) -> Union [None , bytes ]:
7878 """
7979 Writes DMAP data from `source` to either a `bytes` object or to `outfile`.
@@ -88,15 +88,17 @@ def write_dispatcher(
8888 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
8989 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
9090 compressed using bzip2.
91+ bz2: bool
92+ If `True`, the data will be compressed with `bzip2`.
9193 """
9294 if fmt not in ["dmap" , "iqdat" , "rawacf" , "fitacf" , "grid" , "map" , "snd" ]:
9395 raise ValueError (
9496 f"invalid fmt `{ fmt } `: expected one of ['dmap', 'iqdat', 'rawacf', 'fitacf', 'grid', 'map', 'snd']"
9597 )
9698 if outfile is None :
97- return getattr (dmap_rs , f"write_{ fmt } _bytes" )(source )
99+ return getattr (dmap_rs , f"write_{ fmt } _bytes" )(source , bz2 = bz2 )
98100 elif isinstance (outfile , str ):
99- getattr (dmap_rs , f"write_{ fmt } " )(source , outfile )
101+ getattr (dmap_rs , f"write_{ fmt } " )(source , outfile , bz2 = bz2 )
100102 else :
101103 raise TypeError (
102104 f"invalid type for `outfile` { type (outfile )} : expected `str` or `None`"
@@ -308,7 +310,7 @@ def read_snd(
308310
309311
310312def write_dmap (
311- source : list [dict ], outfile : Union [None , str ] = None
313+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
312314) -> Union [None , bytes ]:
313315 """
314316 Writes DMAP data from `source` to either a `bytes` object or to `outfile`.
@@ -321,12 +323,14 @@ def write_dmap(
321323 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
322324 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
323325 compressed using bzip2.
326+ bz2: bool
327+ If `True`, the data will be compressed with `bzip2`.
324328 """
325- return write_dispatcher (source , "dmap" , outfile )
329+ return write_dispatcher (source , "dmap" , outfile , bz2 = bz2 )
326330
327331
328332def write_iqdat (
329- source : list [dict ], outfile : Union [None , str ] = None
333+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
330334) -> Union [None , bytes ]:
331335 """
332336 Writes IQDAT data from `source` to either a `bytes` object or to `outfile`.
@@ -339,12 +343,14 @@ def write_iqdat(
339343 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
340344 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
341345 compressed using bzip2.
346+ bz2: bool
347+ If `True`, the data will be compressed with `bzip2`.
342348 """
343- return write_dispatcher (source , "iqdat" , outfile )
349+ return write_dispatcher (source , "iqdat" , outfile , bz2 = bz2 )
344350
345351
346352def write_rawacf (
347- source : list [dict ], outfile : Union [None , str ] = None
353+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
348354) -> Union [None , bytes ]:
349355 """
350356 Writes RAWACF data from `source` to either a `bytes` object or to `outfile`.
@@ -357,12 +363,14 @@ def write_rawacf(
357363 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
358364 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
359365 compressed using bzip2.
366+ bz2: bool
367+ If `True`, the data will be compressed with `bzip2`.
360368 """
361- return write_dispatcher (source , "rawacf" , outfile )
369+ return write_dispatcher (source , "rawacf" , outfile , bz2 = bz2 )
362370
363371
364372def write_fitacf (
365- source : list [dict ], outfile : Union [None , str ] = None
373+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
366374) -> Union [None , bytes ]:
367375 """
368376 Writes FITACF data from `source` to either a `bytes` object or to `outfile`.
@@ -375,12 +383,14 @@ def write_fitacf(
375383 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
376384 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
377385 compressed using bzip2.
386+ bz2: bool
387+ If `True`, the data will be compressed with `bzip2`.
378388 """
379- return write_dispatcher (source , "fitacf" , outfile )
389+ return write_dispatcher (source , "fitacf" , outfile , bz2 = bz2 )
380390
381391
382392def write_grid (
383- source : list [dict ], outfile : Union [None , str ] = None
393+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
384394) -> Union [None , bytes ]:
385395 """
386396 Writes GRID data from `source` to either a `bytes` object or to `outfile`.
@@ -393,12 +403,14 @@ def write_grid(
393403 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
394404 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
395405 compressed using bzip2.
406+ bz2: bool
407+ If `True`, the data will be compressed with `bzip2`.
396408 """
397- return write_dispatcher (source , "grid" , outfile )
409+ return write_dispatcher (source , "grid" , outfile , bz2 = bz2 )
398410
399411
400412def write_map (
401- source : list [dict ], outfile : Union [None , str ] = None
413+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
402414) -> Union [None , bytes ]:
403415 """
404416 Writes MAP data from `source` to either a `bytes` object or to `outfile`.
@@ -411,12 +423,14 @@ def write_map(
411423 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
412424 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
413425 compressed using bzip2.
426+ bz2: bool
427+ If `True`, the data will be compressed with `bzip2`.
414428 """
415- return write_dispatcher (source , "map" , outfile )
429+ return write_dispatcher (source , "map" , outfile , bz2 = bz2 )
416430
417431
418432def write_snd (
419- source : list [dict ], outfile : Union [None , str ] = None
433+ source : list [dict ], outfile : Union [None , str ] = None , bz2 : bool = False ,
420434) -> Union [None , bytes ]:
421435 """
422436 Writes SND data from `source` to either a `bytes` object or to `outfile`.
@@ -429,5 +443,7 @@ def write_snd(
429443 If `None`, returns the data as a `bytes` object. If this is a string, then this is interpreted as a path
430444 and data will be written to the filesystem. If the file ends in the `.bz2` extension, the data will be
431445 compressed using bzip2.
446+ bz2: bool
447+ If `True`, the data will be compressed with `bzip2`.
432448 """
433- return write_dispatcher (source , "snd" , outfile )
449+ return write_dispatcher (source , "snd" , outfile , bz2 = bz2 )
0 commit comments