Re: [Rest2web-develop] RE: File Bug
Brought to you by:
mjfoord
From: Fuzzyman <fuz...@vo...> - 2006-04-07 13:10:44
|
Andrew Ittner wrote: > Here is some debug output for the root's index: > self.dir=; filename=index.txt; entry=rest2web140x62.gif; > src=index.txt/rest2web140x62.gif > > So this works fine. > And for projects/rest2web's index: > self.dir=projects/rest2web; filename=projects/rest2web/index.txt; > entry=halloffamelogo.png; > src=projects/rest2web/projects/rest2web/index.txt/halloffamelogo.png > > This line: > src = join(self.dir, dirname(filename), entry) > > will concatenate the current directory, AND the current directory of a file > in the current directory, and THEN the filename. So you end up with > DIR/SUBDIR/DIR/SUBDIR/filename.ext. > > Yup - I understand. I think the method ``get_real_restindex`` is doing this to the filename - so I will work out a generic method of solving this. I wonder why this worked for me though ? > Since you want to merge these 2 loops, perhaps I should wait to add a fix. > Here's what I recommend: compare self.dir and dirname(filename)'s results: > if they match, use only one. If they don't, use one. I think we need a > complete test suite on this one, because you talked about setting the > index-file option, which I do not use in combination with the file keyword. > I am not currently using the file keyword at all, I do however use the index-file keyword quite a lot, so it is important to me that this works correctly. I will sort it out. Thanks for your help in diagnosing this. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > Andrew > > -----Original Message----- > From: res...@li... > [mailto:res...@li...]On Behalf Of Michael > Foord > Sent: Thursday, April 06, 2006 12:15 AM > To: res...@li... > Subject: Re: [Rest2web-develop] RE: File Bug > > > > > > On 06/04/06, Andrew Ittner <and...@us...> wrote: > I love one-line fixes. > > Changed > src = join(self.dir, filename, entry) > > > But in SVN I had already changed that line to : > > src = join(self.dir, dirname(filename), entry) > > ??? Because I'd like to move the two chunks of code into a single function, > that dirname will be needed for the case of index files. > > I'll make that change and you can test again. :-) > > Fuzzyman > http://ww.voidspace.org.uk/python/index.shtml > > > > to > src = join(self.dir, entry) > > It appears that the filename value set the path to > "index.txt /thefilename.ext" instead of just "thefilename.ext". Once I > removed it, both the index and non-index pages copied files fine (so I did > not need to change the other loop's src line). > > Andrew > > >> -----Original Message----- >> From: Fuzzyman [mailto:fuz...@vo...] >> Sent: Tuesday, April 04, 2006 2:34 AM >> To: res...@li...; Andrew Ittner >> Subject: Re: File Bug >> >> >> Hello Andrew, >> >> I would certainly appreciate your eyes in tracking down this bug. I >> don't *think* it can be platform specific though, as there is no >> platform specific code (I use platform independent functions from >> ``os.path`` and ``shutil`` to do all the work). >> >> I can see where the bug is happening - for you it seems to be where the >> location of the source file is determined. I've pasted the full code in >> below - and explained the logic of the first part which determines the >> source location. You could add in a print statement to see where it >> thinks the source file *should be*, which will give us a clue as to what >> is happening. >> >> The code exists twice (which means it ought to be turned into a method >> of Processor). Once in the ``process`` method and once in the >> ``processindex`` method. >> >> When rest2web starts, it changes the current directory to be the 'start' >> directory (top level of the site directory tree). >> >> As it goes through the files, the current directory being worked on is >> stored in ``self.dir`` (self being the processor instance). At the top >> level directory the following is set in ``__init__``, ``self.dir = >> os.curdir``. (Is it possible that this is the cause of the problem ?) >> >> Following code taken from - >> http://rest2web.python-hosting.com/file/trunk/rest2web/restprocessor.py >> - from the process method. >> >> # also copy files (from restindex) into same dir as target >> for entry in restindex['file']: >> src = join(self.dir, dirname(filename), entry) >> ## XXX Add a ``print src`` here :-) >> if not os.path.isfile(src): >> print ('File "%s" referenced by file keyword missing.' % >> entry) >> continue >> # >> target_file_name = url2pathname(target) >> targetfile = os.path.normpath(join( >> self.target, self.dir, target_file_name)) >> dest = join(dirname(targetfile), split(entry)[1]) >> comparefile = os.path.normpath(join( >> self.compare, self.dir, target_file_name)) >> cmp = join(dirname(comparefile), split(entry)[1]) >> if comparefiles(src, cmp): >> print 'File "%s" identical, skipping.' % entry >> continue >> if not isdir(dirname(dest)): >> os.makedirs(dirname(dest)) >> print 'Copying "%s".' % entry >> copy2(src, dest) # alias for shutil.copy2 >> >> I'll step through the code to explain the process. >> >> for entry in restindex['file']: >> >> restindex['file'] should be a list of all your file keywords from the >> page being processed. >> >> >> src = join(self.dir, dirname(filename), entry) >> >> ``join`` is an alias for ``os.path.join``. >> >> ``filename`` is the name of the file being processed. When we are >> processing an index file, it could actually be a path relative to >> ``self.dir`` if the ``index-file`` option is set. >> >> You were getting lots of ``File "..." referenced by file keyword >> missing.`` errors - so this logic seems to be faulty ? >> >> If you add the print statement I suggest, then you should be able to >> tell what is happening. I'm sure the solution is simple enough - but I >> can't see it. >> >> Thanks >> >> Fuzzyman >> http://www.voidspace.org.uk/python/index.shtml >> > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > > |