GNOME Bugzilla – Bug 639906
Printing out more easily readable information
Last modified: 2018-06-29 22:52:21 UTC
Created attachment 178675 [details] [review] This patch adds a __str__ function to GncNumeric When accessing the objects of the python-bindings i would like to have a nicer representation of the different objects. I don't know the possibilities very well so I try. This first patch adds a __str__ function to GncNumeric which makes it possible to have >> g=gnucash.GncNumeric(1,2) >> print g 0.5 >> g <gnucash.gnucash_core.GncNumeric object at 0xb5168bcc> This seems very nice to me. I wonder if this would be useful for the more Complex objects or if there would be a better solution.
Comment on attachment 178675 [details] [review] This patch adds a __str__ function to GncNumeric Please add a special treatment for the error case denom == 0. Otherwise, the patch is fine :-)
Created attachment 178702 [details] [review] Adding __str__ and __unicode__ methods to GncNumeric 1) I decided to let the methods return "Division by Zero" for denom()==0. 2) As proposed in http://stackoverflow.com/questions/1307014/python-str-versus-unicode i created both __str__ and __unicode__. 3) I use format to fix the decimal places to 2. It would be nice if the number would be configurable.
Comment on attachment 178702 [details] [review] Adding __str__ and __unicode__ methods to GncNumeric r20128, thanks!
Created attachment 178891 [details] [review] This patch adds a __str__ and __unicode__ method to Split and Transaction Thanks for committing my patch ! For the more complex financial objects i chose a different approach. The printing functions are located in one module. Importing this module adds these functions as methods to the classes defined in gnucash_core.py. Attention to committing person: This patch introduces a new file "str_methods.py".
Comment on attachment 178891 [details] [review] This patch adds a __str__ and __unicode__ method to Split and Transaction r20145, thanks!
Created attachment 179087 [details] [review] Changing the way Strings are formatted in Subfunctions Split and Transaction the __format__ function does not offer a functionality to cut values that are too long. In this patch i use a Class ClassWithCutting__format__ which is wrapped around every value that should be formatted. It's __format__-function uses the standardsyntax but is changed so that it cuts values. In this way a list of Splits can be printed out nicely.
Created attachment 179088 [details] [review] Changing the way __format__ works for Split and Transaction
Created attachment 179111 [details] [review] Changing the way __format__ works for Split and Transaction Some small changes.
Created attachment 179149 [details] [review] Changing the way __format__ works for Split and Transaction Small bugfix
Comment on attachment 179149 [details] [review] Changing the way __format__ works for Split and Transaction r20263, thanks!
Created attachment 188696 [details] [review] patch against Revision 20689. str_methods.py improved.
The previous patch: str_methods.py - added a flagging system to change the output of the __str__ methods - added unicode and str-methods to invoice and entry function_class.py - added modified add_method and add_classmethods to implement the previous gnucash_business.py - add methods_return_instance_lists for method Invoice.GetEntries
Comment on attachment 188696 [details] [review] patch against Revision 20689. str_methods.py improved. r20695, thanks!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=639906. Please update any external references or bookmarks.