Hi list,
Hi Aurelio,
as the "suspicious" line is apparently still there, I had an other and
longer look at this part of the code. It seems the problem come from the
fact that if the config file is processed because of a command line
option, the target could be unknown at this point. Hence, no filtering
of the rules according to the target can be done.
I propose a patch that, if necessary, waits for the target to be
known before dropping unnecessary rules. It seems to solve the problem.
Comments welcomed,
Cheers
Emmanuel
From: Aurélio Jargas <ve...@au...> - 2008-04-30 03:12
> Hello Emmanuel,
>
> Let's see...
>
> $ cat myfile
> %!preproc(html): TARGET html
> %!preproc(tex): TARGET tex
>
> $ cat foo.t2t
>
> %!includeconf: myfile
> TARGET
>
> $ txt2tags -t txt -H -o- foo.t2t
> TARGET
>
> $ txt2tags -t txt --config-file=myfile -H -o- foo.t2t
> html
>
> $
>
> Bug confirmed. And yes, I guess your suspicious line is the culprit.
> Now I just need to remember why the heck it was needed on the first
> place :)
>
> I'll try to fix it for the next version, thank you for the detailed
report!
>
> Bye
>
>
>
> On Thu, Apr 17, 2008 at 9:10 AM, Emmanuel Godard
> <emmanuel.god...@cm...> wrote:
> > Hi list,
> > Hi Aurelio,
> >
> > There is something I don't understand, or maybe I don't know how
to get
> > it right. If I put some configs in a file and call them by
> > %!includeconf: myfile
> > everything is OK. If I use the command line instead, with
> > --config-file=myfile
> > some stuff is broken. In particular it's seems that target specific
> > rules (like
> > %!preproc(html): TARGET html
> > %!preproc(tex): TARGET tex
> > )
> > are now not so specific. The last one overrides the previous for any
> target.
> >
> > Looking inside the script, I have found a "suspicious" comment line
> > 1543, in the method get_raw_config:
> > # Remove the 'target' item of all configs
> >
> > What do you think it is?
> >
> > --
> > Emmanuel
> >
> >
> >
>
--- txt2tags (revision 84)
+++ txt2tags (patch bug-C level 1)
@@ -2206,6 +2206,14 @@
Error(_("%s (try --help)")%errmsg)
return (opts, args)
+ def targetify(self,target,configs):
+ # Keep only the target related items from configs
+ newconfigs=[]
+ for c in configs:
+ if c[0]==target or c[0]=='all':
+ newconfigs.append([c[1],c[2]])
+ return newconfigs
+
def get_raw_config(self, cmdline=[], ignore=[], filter=[], relative=0):
"Returns the options/arguments found as RAW config"
if not cmdline: return []
@@ -2214,6 +2222,8 @@
if type(cmdline) in (type(''), type(u'')):
cmdline = self._tokenize(cmdline)
opts, args = self.parse(cmdline[:])
+ thetarget = ''
+ theconfigs = []
# Parse all options
for name,value in opts:
# Remove leading - and --
@@ -2230,10 +2240,18 @@
# config-file inclusion, path relative to PWD
if name == 'config-file':
configs = ConfigLines().include_config_file(value)
- # Remove the 'target' item of all configs
- configs = map(lambda c: [c[1],c[2]], configs)
- ret.extend(configs)
+ # If possible, remove the unnecessary 'target' item of all configs
+ if thetarget != '': # target already known
+ ret.extend(self.targetify(thetarget,configs))
+ else: # targetify later
+ theconfigs = configs
continue
+ # Deal with potential target specifics from config file
+ if name == 'target':
+ if theconfigs != []: # configs already known
+ ret.extend(self.targetify(value,theconfigs))
+ else: # targetify later
+ thetarget=value
# Save it
ret.append([name, value])
# Get infile, if any
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list