[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [PATCH 03/27] Use python .replace instead than re.sub in Meta
From: |
Matthew White |
Subject: |
[Bug-wget] [PATCH 03/27] Use python .replace instead than re.sub in Metalink tests |
Date: |
Thu, 29 Sep 2016 06:02:43 +0200 |
* testenv/Test-metalink-http.py: Use python .replace
* testenv/Test-metalink-xml.py: Use python .replace
* testenv/Test-metalink-xml-abspath.py: Use python .replace
* testenv/Test-metalink-xml-relpath.py: Use python .replace
Use python .replace instead than re.sub, remove 'import re'.
---
testenv/Test-metalink-http.py | 7 +++----
testenv/Test-metalink-xml-abspath.py | 7 +++----
testenv/Test-metalink-xml-relpath.py | 7 +++----
testenv/Test-metalink-xml.py | 7 +++----
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/testenv/Test-metalink-http.py b/testenv/Test-metalink-http.py
index 993642b..b119da6 100755
--- a/testenv/Test-metalink-http.py
+++ b/testenv/Test-metalink-http.py
@@ -2,7 +2,6 @@
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
-import re
import hashlib
from base64 import b64encode
@@ -12,9 +11,9 @@ from base64 import b64encode
# Helper function for hostname, port and digest substitution
def SubstituteServerInfo (text, host, port, digest):
- text = re.sub (r'{{FILE1_HASH}}', digest, text)
- text = re.sub (r'{{SRV_HOST}}', host, text)
- text = re.sub (r'{{SRV_PORT}}', str (port), text)
+ text = text.replace('{{FILE1_HASH}}', digest)
+ text = text.replace('{{SRV_HOST}}', host)
+ text = text.replace('{{SRV_PORT}}', str (port))
return text
############# File Definitions ###############################################
diff --git a/testenv/Test-metalink-xml-abspath.py
b/testenv/Test-metalink-xml-abspath.py
index b618ca0..4447b0e 100755
--- a/testenv/Test-metalink-xml-abspath.py
+++ b/testenv/Test-metalink-xml-abspath.py
@@ -2,7 +2,6 @@
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
-import re
import hashlib
"""
@@ -77,9 +76,9 @@ http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
-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)
+MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
+MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
+MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
MetaFile.content = MetaXml
err = http_test.begin ()
diff --git a/testenv/Test-metalink-xml-relpath.py
b/testenv/Test-metalink-xml-relpath.py
index 5ecb2b4..c565302 100755
--- a/testenv/Test-metalink-xml-relpath.py
+++ b/testenv/Test-metalink-xml-relpath.py
@@ -2,7 +2,6 @@
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
-import re
import hashlib
"""
@@ -77,9 +76,9 @@ http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
-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)
+MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
+MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
+MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
MetaFile.content = MetaXml
err = http_test.begin ()
diff --git a/testenv/Test-metalink-xml.py b/testenv/Test-metalink-xml.py
index 2541a38..fdeede6 100755
--- a/testenv/Test-metalink-xml.py
+++ b/testenv/Test-metalink-xml.py
@@ -2,7 +2,6 @@
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
-import re
import hashlib
"""
@@ -77,9 +76,9 @@ http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
-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)
+MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
+MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
+MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
MetaFile.content = MetaXml
err = http_test.begin ()
--
2.7.3
- [Bug-wget] [PATCH v2 01/27] new Metalink functionalities, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 02/27] Fix: Change Metalink/XML v3 file name into test.metalink, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 01/27] Add two Metalink/XML tests, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 03/27] Use python .replace instead than re.sub in Metalink tests,
Matthew White <=
- [Bug-wget] [PATCH 04/27] Add metalink description, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 05/27] Bugfix: Fix NULL filename and output_stream in Metalink module, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 06/27] Bugfix: Keep the download progress when alternating metalink:url, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 07/27] Update Metalink/XML tests and add a new test for home paths, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 09/27] Change mfile->name to filename in Metalink module's messages, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 08/27] Add file size computation in Metalink module, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 10/27] Implement Metalink/XML --directory-prefix option in Metalink module, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 11/27] Enforce Metalink file name verification, strip directory if necessary, Matthew White, 2016/09/29
- [Bug-wget] [PATCH 12/27] New document: Metalink/XML and Metalink/HTTP standard reference, Matthew White, 2016/09/29