Re: [Rest2web-develop] RE: File Bug
Brought to you by:
mjfoord
|
From: Michael F. <fuz...@gm...> - 2006-04-06 07:14:37
|
On 06/04/06, Andrew Ittner <and...@us...> wrote:
>
> I love one-line fixes.
>
> Changed
> src =3D join(self.dir, filename, entry)
But in SVN I had already changed that line to :
src =3D 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 =3D 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 di=
d
> 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 wha=
t
> > 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 =3D
> > 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 =3D 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 =3D url2pathname(target)
> > targetfile =3D os.path.normpath(join(
> > self.target, self.dir, target_file_name))
> > dest =3D join(dirname(targetfile), split(entry)[1])
> > comparefile =3D os.path.normpath(join(
> > self.compare, self.dir, target_file_name))
> > cmp =3D 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 =3D 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=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Rest2web-develop mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/rest2web-develop
>
--
http://www.Voidspace.org.uk
The Place where headspace meets cyberspace. Online resource site - covering
science, technology, computing, cyberpunk, psychology, spirituality, fictio=
n
and more.
---
http://www.Voidspace.org.uk/python/index.shtml
Python utilities, modules and apps.
Including Nanagram, Dirwatcher and more.
---
http://www.fuchsiashockz.co.uk
http://groups.yahoo.com/group/void-shockz
---
Everyone has talent. What is rare is the courage to follow talent
to the dark place where it leads. -Erica Jong
Ambition is a poor excuse for not having sense enough to be lazy.
-Milan Kundera
|