bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH 01/25] Add two Metalink/XML tests


From: Giuseppe Scrivano
Subject: Re: [Bug-wget] [PATCH 01/25] Add two Metalink/XML tests
Date: Sun, 11 Sep 2016 21:52:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi Matthew,

thanks for all your work, I am going to comment on each patch separately:

Matthew White <address@hidden> writes:


> index 0000000..041d772
> --- /dev/null
> +++ b/testenv/Test-metalink-xml-relpath.py
> @@ -0,0 +1,87 @@
> +#!/usr/bin/env python3
> +from sys import exit
> +from test.http_test import HTTPTest
> +from misc.wget_file import WgetFile
> +import re
> +import hashlib
> +
> +"""
> +    This is to test if Metalink XML file escapes current directory.
> +"""
> +############# File Definitions 
> ###############################################
> +File1 = "Would you like some Tea?"
> +File1_lowPref = "Do not take this"
> +File1_sha256 = hashlib.sha256 (File1.encode ('UTF-8')).hexdigest ()
> +MetaXml = \
> +"""<?xml version="1.0" encoding="utf-8"?>
> +<metalink version="3.0" xmlns="http://www.metalinker.org/";>
> +  <publisher>
> +    <name>GNU Wget</name>
> +  </publisher>
> +  <license>
> +    <name>GNU GPL</name>
> +    <url>http://www.gnu.org/licenses/gpl.html</url>
> +  </license>
> +  <identity>Wget Test File 1</identity>
> +  <version>1.2.3</version>
> +  <description>Wget Test File 1 description</description>
> +  <files>
> +    <file name="../File1">

If the difference between the two files is only here, could we have only
one test file and another template substition for file name?  Somethging
like <file name="{{FILE}}">?


> +MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml)
> +MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml)
> +MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml)
> +MetaFile.content = MetaXml

should be enough to use replace instead of the re module?

MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)

Thanks,
Giuseppe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]