Em Tue, May 19, 2015 at 05:20:21PM +0200, Petr Oros escreveu:
Arnaldo Carvalho de Melo píše v Út 19. 05. 2015 v 11:10 -0300:
> Em Tue, May 19, 2015 at 09:29:11AM +0200, Petr Oros escreveu:
> > 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
>
> Why is it bad?
>
> > use config ONLY over this class. I don't know where can use this
> > conversion directly. Class method protect to potential bad use.
>
> Can you think of one?
These helpers are related to config class code. Python is object
That is perfectly ok to leave them in that file then, just like lots of
other global functions in the tuna code.
oriented language and, i just don't see reason why move functions
They are not related to the config class code, if they were it would be
using self, no? I.e. are those methods dealing with internal state of
this class?
The fact that a language is object oriented doesn't preclude using
normal functions.
somewhere into space. I created them for better outline and for
specific usage, not globally for some magic anywhere.
There is no magic involved, its just logic, the code is not related to
the class as it doesn't touch its internal state.
- Arnaldo