from
Wolfgang Grafen <wolfgang.grafen at marconi dot com>
to
Sylvain Thénault <thenault at nerim dot net>
subject
Re: pylint0.2 common0.3.3 AttributeError: 'list' object has no attribute
'pure_python'
date
Sylvain Thénault wrote:2003/10/13 11:30
>
> On Friday 10 October à 18:42, Wolfgang Grafen wrote:
> > Hi Sylvain,
>
> Hi !
>
> > 1 #!/user/freepool/local/bin/python2.3
> > 2 import re
> > 3
> > 4 re_default_arch = re.compile("^a\d+").match
> > 5
> > 6 def get_vhdlinfo(vhdl_architecture_fname):
> > 7 # upifmain_upsfrontloop-xp-ar.vhd
> > 8 entityname,arch,misc = vhdl_architecture_fname.split('-')
> > 9
> > 10 for_modulename = entityname.split("upifmain_ups")[1]
> > 11 if not re_default_arch(arch):
> > 12 upein_path = "stim/%(for_modulename)s_%(arch)s_up.ein" % vars()
> > 13
> > 14 else:
> > 15 upein_path = "stim/%(for_modulename)s_up.ein" % vars()
> > 16
> > 17 upregsigname = "%(entityname)s-sigs" % vars()
> > 18
> > 19 def main(vhdl_architecture_fname):
> > 20 pass
> > 21
> > 22 if __name__ == '__main__':
> > 23 vhdl_architecture_fnames = []
> > 24 for vhdl_architecture_fname in vhdl_architecture_fnames:
> > 25 architecture_txt,configuration_txt,subst_dict = main(
> > 26 vhdl_architecture_fname)
> > (END)
> >
> >
> > chios upifmain_upsstaticgen 91 % pylint pylint_example.py
> > No config file found, using default configuration
> > ************* Module pylint_example
> > W: 0: Missing docstring
> > W: 0: Missing required attribute "__revision__"
> > W: 6:get_vhdlinfo: Missing docstring
> > W: 6:get_vhdlinfo: Redefining variable (vhdl_architecture_fname) from outer scope (line 24)
> > W: 17:get_vhdlinfo: Unused variable upregsigname
> > W: 10:get_vhdlinfo: Unused variable for_modulename
> > it is used in line 12 and 15
>
> well, pylint doesn't look for used variables in string. And I'm not sure
> it will detect a variable use in such a statement one day...
Why not? I think this is a quite common use for generating HTML used with many CGI or other web application
and other code generation. I didn't have the time yet to analyse how your code works but the algorithm behind
doesn't seem too difficult for me. Check whether the yet not used variable is in the % operator's dict (vars()).
Convert the string(object) into a dictionary and look whether it has the key. Of course the algorithm becomes
more difficult if it should work with arbitrary objects, but a first simple integration is better than never
implement the best.
best regards
wolfgang
