[82c348c] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 |
|
---|
| 3 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 4 | version="1.0">
|
---|
| 5 |
|
---|
| 6 | <xsl:output method="text"/>
|
---|
| 7 |
|
---|
[fc82888] | 8 | <!-- The pyhosted-inc.xsl file contains two variables, one containing
|
---|
| 9 | the text of
|
---|
| 10 | pythonhosted.xml before the creation of pythonhosted-files.md5,
|
---|
| 11 | the other containing the text after that.-->
|
---|
[82c348c] | 12 | <xsl:include href="pyhosted-inc.xsl"/>
|
---|
[fc82888] | 13 | <!-- list of python modules whose dependencies should be listed -->
|
---|
[82c348c] | 14 | <xsl:param name="packages">requests sphinx_rtd_theme pytest</xsl:param>
|
---|
[fc82888] | 15 | <!-- Name of the .xml where to find all python dependencies -->
|
---|
[82c348c] | 16 | <xsl:variable name="python-deps">python-dependencies.xml</xsl:variable>
|
---|
[fc82888] | 17 | <!-- This variable is a scan of the dependency graph in depth first order.
|
---|
| 18 | it is a suitable order for building, except it contains many
|
---|
| 19 | duplicates.-->
|
---|
[82c348c] | 20 | <xsl:variable name="raw-dep-list">
|
---|
| 21 | <xsl:call-template name="gen-deps">
|
---|
| 22 | <xsl:with-param name="list" select="$packages"/>
|
---|
| 23 | </xsl:call-template>
|
---|
| 24 | </xsl:variable>
|
---|
[fc82888] | 25 | <!-- This variable is a copy of raw-dep-list, but with duplicates removed -->
|
---|
[82c348c] | 26 | <xsl:variable name="dep-list">
|
---|
| 27 | <xsl:call-template name="make-unique">
|
---|
| 28 | <xsl:with-param name="list" select="$raw-dep-list"/>
|
---|
| 29 | <xsl:with-param name="temp" select="' '"/>
|
---|
| 30 | </xsl:call-template>
|
---|
| 31 | </xsl:variable>
|
---|
| 32 |
|
---|
[fc82888] | 33 | <!-- scan the list of modules and generates dependencies for each -->
|
---|
[82c348c] | 34 | <xsl:template name="gen-deps">
|
---|
| 35 | <xsl:param name="list" select="$packages"/>
|
---|
| 36 | <xsl:choose>
|
---|
| 37 | <xsl:when test="contains($list,' ')">
|
---|
| 38 | <xsl:call-template name="gen-deps">
|
---|
| 39 | <xsl:with-param name="list" select="substring-before($list,' ')"/>
|
---|
| 40 | </xsl:call-template>
|
---|
| 41 | <xsl:call-template name="gen-deps">
|
---|
| 42 | <xsl:with-param name="list" select="substring-after($list,' ')"/>
|
---|
| 43 | </xsl:call-template>
|
---|
| 44 | </xsl:when>
|
---|
| 45 | <xsl:otherwise>
|
---|
| 46 | <xsl:apply-templates select="id($list)" mode="gen-dep"/>
|
---|
| 47 | <xsl:value-of select="$list"/>
|
---|
| 48 | <xsl:text> </xsl:text>
|
---|
| 49 | </xsl:otherwise>
|
---|
| 50 | </xsl:choose>
|
---|
| 51 | </xsl:template>
|
---|
| 52 |
|
---|
[fc82888] | 53 | <!-- This template is applied recursively for each dependency. -->
|
---|
[82c348c] | 54 | <xsl:template match="*" mode="gen-dep">
|
---|
[fc82888] | 55 | <!-- for debugging
|
---|
[82c348c] | 56 | <xsl:message>
|
---|
| 57 | <xsl:text>generating deps for </xsl:text>
|
---|
| 58 | <xsl:value-of select="@id"/>
|
---|
| 59 | <xsl:text>
|
---|
| 60 | </xsl:text>
|
---|
| 61 | </xsl:message>
|
---|
[0231d69] | 62 | -->
|
---|
[82c348c] | 63 | <xsl:apply-templates
|
---|
| 64 | select="descendant::para[@role='required' or
|
---|
| 65 | @role='recommended']"
|
---|
| 66 | mode="dep-list"/>
|
---|
| 67 | </xsl:template>
|
---|
| 68 |
|
---|
[fc82888] | 69 | <!-- this template calls the preceding one for each dependency found,
|
---|
| 70 | printing the name of the dependency afterwards. This generates the
|
---|
| 71 | depth-first order -->
|
---|
[82c348c] | 72 | <xsl:template match="para" mode="dep-list">
|
---|
| 73 | <xsl:for-each select="xref">
|
---|
[fc82888] | 74 | <!-- The linkend may point either to the current document, or
|
---|
| 75 | if not found to the python-dependencies.xml document. Note
|
---|
| 76 | that the current document may be already python-dependencies.xml.-->
|
---|
[82c348c] | 77 | <xsl:choose>
|
---|
| 78 | <xsl:when test="//*[@id=current()/@linkend]">
|
---|
| 79 | <xsl:apply-templates select="//*[@id=current()/@linkend]" mode="gen-dep"/>
|
---|
| 80 | <xsl:value-of select="@linkend"/>
|
---|
| 81 | <xsl:text> </xsl:text>
|
---|
| 82 | </xsl:when>
|
---|
| 83 | <xsl:when test="document($python-deps,/)//*[@id=current()/@linkend]">
|
---|
| 84 | <xsl:apply-templates select="document($python-deps,/)//*[@id=current()/@linkend]" mode="gen-dep"/>
|
---|
| 85 | <xsl:value-of select="@linkend"/>
|
---|
| 86 | <xsl:text> </xsl:text>
|
---|
| 87 | </xsl:when>
|
---|
| 88 | </xsl:choose>
|
---|
| 89 | </xsl:for-each>
|
---|
| 90 | </xsl:template>
|
---|
| 91 |
|
---|
[fc82888] | 92 | <!-- Template to remove duplicates. Each time it is called, the param
|
---|
| 93 | "list" contains the list remaining to be processed, and the
|
---|
| 94 | param "temp" contains the already processed list with no duplicates -->
|
---|
[82c348c] | 95 | <xsl:template name="make-unique">
|
---|
| 96 | <xsl:param name="list" select="$raw-dep-list"/>
|
---|
| 97 | <xsl:param name="temp" select="' '"/>
|
---|
| 98 | <xsl:choose>
|
---|
| 99 | <xsl:when test="contains($list,' ')">
|
---|
| 100 | <xsl:variable name="package" select="substring-before($list,' ')"/>
|
---|
| 101 | <xsl:variable name="temp1">
|
---|
| 102 | <xsl:choose>
|
---|
[fc82888] | 103 | <!-- the concat is needed to prevent problems with a package
|
---|
| 104 | containing the name of another package -->
|
---|
[82c348c] | 105 | <xsl:when test="contains($temp,concat(' ',$package,' '))">
|
---|
| 106 | <xsl:copy-of select="$temp"/>
|
---|
| 107 | </xsl:when>
|
---|
| 108 | <xsl:otherwise>
|
---|
| 109 | <xsl:copy-of select="$temp"/>
|
---|
| 110 | <xsl:text> </xsl:text>
|
---|
| 111 | <xsl:copy-of select="$package"/>
|
---|
| 112 | </xsl:otherwise>
|
---|
| 113 | </xsl:choose>
|
---|
| 114 | </xsl:variable>
|
---|
| 115 | <xsl:call-template name="make-unique">
|
---|
| 116 | <xsl:with-param name="list" select="substring-after($list,' ')"/>
|
---|
| 117 | <xsl:with-param name="temp" select="$temp1"/>
|
---|
| 118 | </xsl:call-template>
|
---|
| 119 | </xsl:when>
|
---|
| 120 | <xsl:otherwise>
|
---|
| 121 | <xsl:choose>
|
---|
| 122 | <xsl:when test="contains($temp,concat(' ',$list,' '))">
|
---|
| 123 | <xsl:copy-of select="$temp"/>
|
---|
| 124 | </xsl:when>
|
---|
| 125 | <xsl:otherwise>
|
---|
| 126 | <xsl:copy-of select="$temp"/>
|
---|
| 127 | <xsl:text> </xsl:text>
|
---|
| 128 | <xsl:copy-of select="$list"/>
|
---|
| 129 | </xsl:otherwise>
|
---|
| 130 | </xsl:choose>
|
---|
| 131 | </xsl:otherwise>
|
---|
| 132 | </xsl:choose>
|
---|
| 133 | </xsl:template>
|
---|
| 134 |
|
---|
[fc82888] | 135 | <!-- with the variable dep-list, we can apply templates for generating
|
---|
| 136 | the content of the .md5 file. We just have to copy the variables set
|
---|
| 137 | in pyhosted-inc before and after that file -->
|
---|
[82c348c] | 138 | <xsl:template match="/">
|
---|
[fc82888] | 139 | <!-- debug
|
---|
[82c348c] | 140 | <xsl:message>
|
---|
| 141 | <xsl:text>Generating new pythonhosted.xml with list:
|
---|
| 142 | </xsl:text>
|
---|
| 143 | <xsl:value-of select="normalize-space($dep-list)"/>
|
---|
| 144 | <xsl:text>
|
---|
| 145 | </xsl:text>
|
---|
| 146 | </xsl:message>
|
---|
[0231d69] | 147 | -->
|
---|
[82c348c] | 148 | <xsl:value-of select="$part1"/>
|
---|
| 149 | <xsl:call-template name="make-md5">
|
---|
| 150 | <xsl:with-param name="list" select="normalize-space($dep-list)"/>
|
---|
| 151 | </xsl:call-template>
|
---|
| 152 | <xsl:value-of select="$part2"/>
|
---|
| 153 | </xsl:template>
|
---|
| 154 |
|
---|
| 155 | <xsl:template name="make-md5">
|
---|
| 156 | <xsl:param name="list" select="normalize-space($dep-list)"/>
|
---|
| 157 | <xsl:choose>
|
---|
| 158 | <xsl:when test="contains($list,' ')">
|
---|
[e0fff61] | 159 | <xsl:variable name="dep" select="substring-before($list,' ')"/>
|
---|
| 160 | <xsl:choose>
|
---|
| 161 | <!-- requests, docutils, and sphinx are not taken from pythonhosted:
|
---|
| 162 | don't have them in the .md5 file, even commented out -->
|
---|
| 163 | <xsl:when test="$dep='requests' or $dep='docutils' or $dep='sphinx'"/>
|
---|
| 164 | <xsl:otherwise>
|
---|
| 165 | <xsl:call-template name="make-md5">
|
---|
| 166 | <xsl:with-param name="list" select="$dep"/>
|
---|
| 167 | </xsl:call-template>
|
---|
| 168 | <xsl:text>
|
---|
[82c348c] | 169 | </xsl:text>
|
---|
[e0fff61] | 170 | </xsl:otherwise>
|
---|
| 171 | </xsl:choose>
|
---|
[82c348c] | 172 | <xsl:call-template name="make-md5">
|
---|
| 173 | <xsl:with-param name="list" select="substring-after($list,' ')"/>
|
---|
| 174 | </xsl:call-template>
|
---|
| 175 | </xsl:when>
|
---|
| 176 | <xsl:otherwise>
|
---|
[fc82888] | 177 | <!-- first try to find the dependency in python-modules. If so, precede
|
---|
| 178 | it with a `#' -->
|
---|
[82c348c] | 179 | <xsl:apply-templates
|
---|
| 180 | select="id($list)"
|
---|
| 181 | mode="md5-line">
|
---|
| 182 | <xsl:with-param name="first-char" select="'#'"/>
|
---|
| 183 | </xsl:apply-templates>
|
---|
[fc82888] | 184 | <!-- then try in python-dependencies -->
|
---|
[82c348c] | 185 | <xsl:apply-templates
|
---|
| 186 | select="document($python-deps,/)//sect2[@id=$list]"
|
---|
| 187 | mode="md5-line"/>
|
---|
| 188 | </xsl:otherwise>
|
---|
| 189 | </xsl:choose>
|
---|
| 190 | </xsl:template>
|
---|
| 191 |
|
---|
| 192 | <xsl:template match="sect2" mode="md5-line">
|
---|
| 193 | <xsl:param name="first-char" select="''"/>
|
---|
[fc82888] | 194 | <!-- debug
|
---|
[82c348c] | 195 | <xsl:message>
|
---|
| 196 | <xsl:text>Generating md5 for </xsl:text>
|
---|
| 197 | <xsl:value-of select="@id"/>
|
---|
| 198 | <xsl:text>
|
---|
| 199 | </xsl:text>
|
---|
| 200 | </xsl:message>
|
---|
[0231d69] | 201 | -->
|
---|
[82c348c] | 202 | <xsl:copy-of select="$first-char"/>
|
---|
| 203 | <xsl:apply-templates select=".//para[contains(text(),'MD5')]" mode="md5"/>
|
---|
| 204 | <xsl:text> </xsl:text>
|
---|
| 205 | <xsl:apply-templates select=".//para[contains(text(),'HTTP')]" mode="http"/>
|
---|
| 206 | </xsl:template>
|
---|
| 207 |
|
---|
| 208 | <xsl:template match="para" mode="md5">
|
---|
| 209 | <xsl:choose>
|
---|
| 210 | <xsl:when test="contains(substring-after(string(),'sum: '),'
')">
|
---|
| 211 | <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'
')"/>
|
---|
| 212 | </xsl:when>
|
---|
| 213 | <xsl:otherwise>
|
---|
| 214 | <xsl:value-of select="substring-after(string(),'sum: ')"/>
|
---|
| 215 | </xsl:otherwise>
|
---|
| 216 | </xsl:choose>
|
---|
| 217 | </xsl:template>
|
---|
| 218 |
|
---|
| 219 | <xsl:template match="para" mode="http">
|
---|
| 220 | <xsl:call-template name="base">
|
---|
| 221 | <xsl:with-param name="path" select="ulink/@url"/>
|
---|
| 222 | </xsl:call-template>
|
---|
| 223 | </xsl:template>
|
---|
| 224 |
|
---|
| 225 | <xsl:template name="base">
|
---|
| 226 | <xsl:param name="path" select="''"/>
|
---|
| 227 | <xsl:choose>
|
---|
| 228 | <xsl:when test="contains($path,'/')">
|
---|
| 229 | <xsl:call-template name="base">
|
---|
| 230 | <xsl:with-param name="path" select="substring-after($path,'/')"/>
|
---|
| 231 | </xsl:call-template>
|
---|
| 232 | </xsl:when>
|
---|
| 233 | <xsl:otherwise>
|
---|
| 234 | <xsl:value-of select="$path"/>
|
---|
| 235 | </xsl:otherwise>
|
---|
| 236 | </xsl:choose>
|
---|
| 237 | </xsl:template>
|
---|
| 238 | </xsl:stylesheet>
|
---|