Re: [Pyme-help] contants -> constant names? for info
Status: Beta
Brought to you by:
belyi
From: Igor B. <be...@us...> - 2008-08-17 04:50:52
|
Bernhard, That's an interesting idea, but I can't think of a python friendly way to implement it. Constants are basically 'integers' which could have conflicting values from different components. So, whatever mechanism is chosen to convert from an integer to a string should be component specific. Another approach would be to make constants into 'objects' and then convert them to integers when they are passed to gpgme and have __str__() method which prints their name instead of their value but I think it's overkill for just an easier 'verbose' capability. Let me know what implementation exactly you have in mind. Thanks, Igor Bernhard Reiter wrote: > Hi Igor, > I am starting to wonder if it would be practical to have a conversion function > that will return the name of the constant from its value. > > When trying to interpret key.owner_trust or uid.validity, e.g. as in > > key = c.get_key(keyfpr, False) > print "got key: ", key.subkeys[0].fpr, "owner_trust:", key.owner_trust > for uid in key.uids: > print uid.uid, "validity:", uid.validity > > from pyme.constants import validity > gives me the constants, but from there it is difficult to contract > their name. I could use the information from > dir(validity) > ['FULL', 'MARGINAL', 'NEVER', 'ULTIMATE', 'UNDEFINED', 'UNKNOWN', > '__builtins__', '__doc__', '__file__', '__name__', 'util'] > > but this would not be conclusive as there could be more integers in there. > So in the end I would need to make my own list of the six values, which is > not helpful. Why not have process_constants() create a sole table as well? > > I think there are quite a few use cases for this. > Especially when trying to print extra information about what has happened, > this is in the debug case, but also in the general "verbose" information case. > > Best, > Bernhard > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ------------------------------------------------------------------------ > > _______________________________________________ > Pyme-help mailing list > Pym...@li... > https://lists.sourceforge.net/lists/listinfo/pyme-help > |