Arnaldo Carvalho de Melo píše v Po 18. 05. 2015 v 16:37 -0300:
> Em Mon, May 18, 2015 at 02:50:25PM -0400, John Kacur escreveu:
> > Yeah, it was also in response to me pointing the bz out to him. I'm
> > testing it as well, I would like to wait for your patch-review
> > Arnaldo before
> > I grab this fix.
> > ----- Original Message -----
> > > I guess this was in response to my report, right? So it would be
> > > nice to
> > > have:
> > >
> > > Reported-by: Arnaldo Carvalho de Melo <acme(a)redhat.com>
> > > Fixes:
https://bugzilla.redhat.com/..../bz-number
> > >
> > > I will review and test later, thanks for the patch!
> > >
> > > - Arnaldo
>
> Seems to work as advertised:
>
> > > > def ConfigPathToFileName(self, configpath):
> ... return configpath.replace(".",
"/").replace("\\/", ".")
> ...
> > > > def FileNameToConfigPath(self, filename):
> ... return filename.replace(".",
"\\.").replace("/", ".")
> ...
> > > > filename="/proc/sys/net/ipv4/neigh/tuna.1"
> > > > config=FileNameToConfigPath(None, filename)
> > > > print config
> .proc.sys.net.ipv4.neigh.tuna\.1
> > > > print ConfigPathToFileName(config)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: ConfigPathToFileName() takes exactly 2 arguments (1 given)
> > > > print ConfigPathToFileName(None, config)
> /proc/sys/net/ipv4/neigh/tuna.1
> > > >
>
> But then I don't know why that has to be a class method instead of a
> global
> function, since it is not specific to that class, see how 'self' is
> not used at
> all, and os potentially useful for other cases dealing with filenames
> as config
> keys.
>
> So I'd recommend to make those global functions, outside this class.
It's conversion config <-> filesystem. Direct access is bad. Tuna can
use config ONLY over this class. I don't know where can use this
conversion directly. Class method protect to potential bad use.
Just my opinion, if you still think, use as global is better, i will
do
it.