/srv/irclogs.ubuntu.com/2014/11/14/#bzr.txt

=== Spads_ is now known as Spads
aquariusI'd like to do the equivalent of bzr cat from a Python script -- that is, write a function which takes an lp URL for a file and returns the content of that file. Is the best approach to call the bzr cat command object and give it a StringIO to output into (which I can't work out how to do), or to do the things that the command object *does* myself?11:32
aquariusI *think* the way to do it is this:11:38
aquariusfrom bzrlib.plugin import load_plugins;load_plugins();from bzrlib.branch import Branch;remote_branch_url = 'lp:~sil/+junk/ucs-demo-app';b = Branch.open(remote_branch_url); tree=b.basis_tree(); file_id=tree.path2id('ubuntu_component_store.json'); print tree.get_file_text(file_id)11:39
james_waquarius: that looks about right11:42
aquariuscool, I'm not doing anything insane, then :)11:42
aquariusam I better to check the file exists with tree.has_id first, or do I end up hitting the network twice then and so I should just catch exceptions on tree.path2id?11:43
james_waquarius: catching an exception makes more sense I thinnk11:45
james_waquarius: or I think it returns None in fact11:45
aquariuscool, then I'll just do it and check :)11:45
=== ciampix_ is now known as ciampix

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!