Re: [chirp_devel] [developer] Control address format for full-file dump/diff - #1767
I appreciate the explanation of how to possibly work around the initial problem, but my proposed solution is less work, less code, tested, just as flexible wrt to controlling the format, and results IMO in a friendlier and more robust interface.
Did you have some reason for not liking that direction?
-dan
On Jul 17, 2014, at 8:05 PM, Dan Smith - dsmith@danplanet.com wrote:
ConfigParser is trying to interpolate those as other configuration variables. You need to pass raw=True to the get() operation. The wrapping around ConfigParser makes that a little tough. Apply this (untested change) to your tree and then pass raw=True in the get call and see if that solves the problem. If so, then you can just include this in your patch:
--- a/chirpui/config.py Mon Jul 14 20:10:30 2014 -0400 +++ b/chirpui/config.py Thu Jul 17 20:04:23 2014 -0700 @@ -36,14 +36,14 @@ self.__config.write(cfg_file) cfg_file.close()
- def get(self, key, section):
def get(self, key, section, raw=False): if not self.__config.has_section(section): return None
if not self.__config.has_option(section, key): return None
return self.__config.get(section, key)
return self.__config.get(section, key, raw=raw)
def set(self, key, value, section): if not self.__config.has_section(section):
@@ -65,8 +65,9 @@ self._config = config self._section = section
- def get(self, key, section=None):
return self._config.get(key, section or self._section)
def get(self, key, section=None, raw=False):
return self._config.get(key, section or self._section,
raw=False)
def set(self, key, value, section=None): return self._config.set(key, value, section or self._section)
--Dan
I appreciate the explanation of how to possibly work around the initial problem, but my proposed solution is less work, less code, tested, just as flexible wrt to controlling the format, and results IMO in a friendlier and more robust interface.
Did you have some reason for not liking that direction?
It's just very limited and the point seems to be to be flexible about how the lines are formatted, right? What if I wanted to see the address, the block size, and the block number? With a format string, I could do this:
%(line_sz)2i * %(i)04i [%(addr)04x]
It just seems like if we're going to do it, we should use a formatted string. If we do the simple thing and then want the more complicated thing later, we have to worry about honoring the old configuration value if present, else the new, or deprecate the old one, etc. It's a trivial amount of work to make it totally flexible, so it seems worth doing. If you don't want to do it, I'll plan to cook up a patch tomorrow to make it flexible and run it by you to see if it works for you, okay?
--Dan
participants (2)
-
chirp.cordless@xoxy.net
-
Dan Smith