Sunday 15 January 2012

Parsing print in python -


How can I parse the other functions? To wit. Function print

  131072 of 1093419 download 393216 of 1093419 download 786432 of 1093419 download 1089536 of 1093419 download   

and I want to create a gauge () Of data.

As @AlexCamberlain says, you have to do the best way to pat the mega library So that you can use its output and make good use of it, you can easily change the code as follows:

In this file you change it, so it is called a callback on all the results instead of printing. They are:

  def download_file (self, file_handle, file_key, dest_path = none, dest_filename = no Ne, is_public = false, file = none, callback = none):   

Then you use that callback. Instead of that line:

  print ('{1} downloaded' {0} format (file_info.st_size, file_size))   

Can be added:

  if callback: callback (file_info.st_size, file_size) Other: print ('{0} downloaded from' {0} 'format (file_info.st_size, file_size) )   

And then you will need to change the prototype of all those functions which call download_file () , e.g. Def download (self, file, dest_path = none, destination_filename = none, callback = none): "" "download a file by this" :

    

and finally you can use the download as follows:

  def myupdater (current, total): print "download {0} / { 1} So far. "Format (current, total) mega.download ('xxx' ',' / tmp ',' fu ', callback = moeupdater)   

Definitely my answer Is not complete Do you have to do this for download_url and find out if you will apply the same pattern to other features like uploading.) But I hope you get this idea, so that you can patch an open source project

NB: To make a patch, you will look at Github's side.

HTH

No comments:

Post a Comment