File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ Change log
1313- Changed the ``assert `` statement for checking the dump version into a
1414 ``raise `` statement since assertions could be optimized out.
1515- Renamed ``InvalidSpec `` to ``InvalidSpecError `` to make ruff happier.
16+ - Added an ``objects `` argument to ``dump_specs `` which allows overriding the
17+ list of objects to dump.
1618
1719
1820`0.5 `_ (2023-03-15)
Original file line number Diff line number Diff line change @@ -89,16 +89,15 @@ def silence(*a):
8989 pass
9090
9191
92- def dump_specs (specs , * , mappers = None ):
92+ def dump_specs (specs , * , mappers = None , objects = None ):
9393 stream = io .StringIO ()
9494 stream .write ('{"version": 1, "specs": ' )
9595 json .dump (specs , stream )
9696 stream .write (', "objects": ' )
9797 serializer = JSONSerializer (mappers = mappers or {})
98- serializer .serialize (
99- chain .from_iterable (_model_queryset (spec ) for spec in specs ),
100- stream = stream ,
101- )
98+ if objects is None :
99+ objects = chain .from_iterable (_model_queryset (spec ) for spec in specs )
100+ serializer .serialize (objects , stream = stream )
102101 stream .write ("}" )
103102 return stream .getvalue ()
104103
You can’t perform that action at this time.
0 commit comments