Export tarball contents using bzrlib

Asked by xaav on 2011-05-27

Is it possible to export the contents of a tarball using bzrlib?

Example Psuedo code:

branch = new Branch("lp:launchpad")

tarballcontents = branch.exportTo("tar.gz");

# Save tarballcontents to file

I'm not looking to export to a file, I'm looking for the contents.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Pool
Solved:
2011-05-27
Last query:
2011-05-27
Last reply:
2011-05-27
Best Martin Pool (mbp) said : #1

Have a look at bzrlib/export/tar_exporter.py. You should be able to
construct a tarball object pointing to for instance a StringIO, then
pass that to export_tarball.

hth
Martin

xaav (xaav) said : #2

Thanks Martin Pool, that solved my question.

Martin Pool (mbp) said : #3

If you're looking at doing this for the benefit of loggerhead
exporting tarballs (which would be so incredibly cool) then you
probably want to avoid building the whole thing in memory, and instead
pass an object which will stream it out as it's produced.

Martin