mirror of
https://github.com/mirror/wget.git
synced 2026-09-06 06:34:56 +08:00
Support substring replace in File Contents too
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2013-09-13 Darshit Shah <darnir@gmail.com>
|
||||||
|
|
||||||
|
* WgetTest.py (CommonMethods._replace_substring): New method that will
|
||||||
|
replace a substring delimited by {{ }} characters by the value of
|
||||||
|
self.<substring> variable
|
||||||
|
(CommonMethods.WgetCommands): Use the _replace_substring () call to
|
||||||
|
replace the substrings in the the command line.
|
||||||
|
(CommonMethods.ServerFiles): Run the _replace_substring () method on
|
||||||
|
the File contents too.
|
||||||
|
|
||||||
2013-09-11 Darshit Shah <darnir@gmail.com>
|
2013-09-11 Darshit Shah <darnir@gmail.com>
|
||||||
|
|
||||||
* WgetTest.py (CommonMethods.exec_wget): Expect domain_list instead of
|
* WgetTest.py (CommonMethods.exec_wget): Expect domain_list instead of
|
||||||
|
|||||||
@@ -105,6 +105,16 @@ class CommonMethods:
|
|||||||
print (local_filesys)
|
print (local_filesys)
|
||||||
raise TestFailed ("Extra files downloaded.")
|
raise TestFailed ("Extra files downloaded.")
|
||||||
|
|
||||||
|
def _replace_substring (self, string):
|
||||||
|
pattern = re.compile ('\{\{\w+\}\}')
|
||||||
|
match_obj = pattern.search (string)
|
||||||
|
if match_obj is not None:
|
||||||
|
rep = match_obj.group()
|
||||||
|
temp = getattr (self, rep.strip ('{}'))
|
||||||
|
string = string.replace (rep, temp)
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
""" Test Rule Definitions """
|
""" Test Rule Definitions """
|
||||||
""" This should really be taken out soon. All this extra stuff to ensure
|
""" This should really be taken out soon. All this extra stuff to ensure
|
||||||
re-use of old code is crap. Someone needs to re-write it. The new rework
|
re-use of old code is crap. Someone needs to re-write it. The new rework
|
||||||
@@ -152,7 +162,8 @@ class CommonMethods:
|
|||||||
file_list = dict ()
|
file_list = dict ()
|
||||||
server_rules = dict ()
|
server_rules = dict ()
|
||||||
for file_obj in server_files[i]:
|
for file_obj in server_files[i]:
|
||||||
file_list[file_obj.name] = file_obj.content
|
content = self._replace_substring (file_obj.content)
|
||||||
|
file_list[file_obj.name] = content
|
||||||
rule_obj = self.get_server_rules (file_obj)
|
rule_obj = self.get_server_rules (file_obj)
|
||||||
server_rules[file_obj.name] = rule_obj
|
server_rules[file_obj.name] = rule_obj
|
||||||
self.server_list[i].server_conf (file_list, server_rules)
|
self.server_list[i].server_conf (file_list, server_rules)
|
||||||
@@ -167,13 +178,7 @@ class CommonMethods:
|
|||||||
""" Test Option Function Calls """
|
""" Test Option Function Calls """
|
||||||
|
|
||||||
def WgetCommands (self, command_list):
|
def WgetCommands (self, command_list):
|
||||||
pattern = re.compile ('\{\{\w+\}\}')
|
self.options = self._replace_substring (command_list)
|
||||||
match_obj = pattern.search (command_list)
|
|
||||||
if match_obj is not None:
|
|
||||||
rep = match_obj.group()
|
|
||||||
temp = getattr (self, rep.strip ('{}'))
|
|
||||||
command_list = command_list.replace (rep, temp)
|
|
||||||
self.options = command_list
|
|
||||||
|
|
||||||
def Urls (self, url_list):
|
def Urls (self, url_list):
|
||||||
self.urls = url_list
|
self.urls = url_list
|
||||||
|
|||||||
Reference in New Issue
Block a user