On 9 June 2014 12:04, Guenter Milde <milde@users.sf.net> wrote:
>
> On 2014-06-08, Guenter Milde wrote:
> > On 2014-06-08, engelbert gruber wrote:
>
> >> [-- Type: text/plain, Encoding: 7bit --]
>
> >> absolute path "/test.css" to me is maybe useful when viewed from a
> >> webserver, but not when viewed on local filesystem.
>
>
> > However, as Docutils should be able to produce HTML files for use from a
> > web server, an absolute css-path setting like
>
> > def suite():
> >     settings = {'stylesheet_path': '/test.css',
> >                 'embed_stylesheet': 0,}
>
> > should be honoured and not be changed.  The spec says: *relative* paths are
> > expanded ...
>
> It seems Python has now a different idea about absoluteness of a path
> after incorporation of PEP 428 (https://docs.python.org/3/whatsnew/3.4.html):
>
>   First a couple of conventions:
>
>   * All paths can have a drive and a root. For POSIX paths, the drive is
>     always empty.
>   * A relative path has neither drive nor root.
>   * A POSIX path is absolute if it has a root. A Windows path is absolute
>     if it has both a drive and a root. A Windows UNC path (e.g.
>     \\host\share\myfile.txt) always has a drive and a root (here,
>     \\host\share and \, respectively).
>   * A path which has either a drive or a root is said to be anchored. Its
>     anchor is the concatenation of the drive and root. Under POSIX,
>     "anchored" is the same as "absolute".

isabs seams a little problematic to me::

  import os.path
  import sys

  for p in ("abc", "/abc", "c:abc", "c:/abc"):
    sys.stdout.write(p)
    sys.stdout.write(" ")
    sys.stdout.write(str(os.path.isabs(p)))
    sys.stdout.write("\n")

returns false, true, false, false on macos for py2.5 2.6 2.7 3.2 and 3.4
on win7 "c:/abc" is true for py 2.7 and 3.4.

maybe os is os-specific and we need something in string-path, because
one might prepare webpages on any os and an absolute path always starts with "/"
or maybe "http://x/" grapping the css from somewhere else ?

should we go back to path.startswith("/") ?

>
>   -- http://legacy.python.org/dev/peps/pep-0428/#making-the-path-relative
>
>
> Does the following patch help restore the behaviour we want?

no , isabs recognzes "/test.css" as absolute.

>
> #> docutils-svn/docutils/docutils/utils > svn diff __init__.py
>
> Index: __init__.py
> ===================================================================
> --- __init__.py (Revision 7743)
> +++ __init__.py (Arbeitskopie)
> @@ -524,7 +524,8 @@
>
>      Return the first expansion that matches an existing file.
>      """
> -    if os.path.isabs(path):
> +    # keep Posix-like absolute paths also on Windows under Py >= 3.4:
> +    if path.startswith('/') or os.path.isabs(path):
>          return path
>      for d in dirs:
>          if d == '.':
>
> Günter
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://www.hpccsystems.com
> _______________________________________________
> Docutils-develop mailing list
> Docutils-develop@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/docutils-develop
>
> Please use "Reply All" to reply to the list.