1# updateweb.yaml
2#
3# Configuration settings for updateweb.py
4#
5# This first YAML document contains web server information.
6---
7ftp_server_name:
8 white husky
9ftp_user_name:
10 white samoyed
11ftp_password:
12 white retriever
13remote_directory:
14 /white/husky/samoyed/retriever
15file_size_limit_Kb:
16 666
17...
18
19
20
21
22
23
24# This second YAML document contains lists of patterns to match and their replacement strings for every line of every source file.
25---
26
27# List each pattern you wish to match and its replacement string.
28# Pattern match/replace will be done in-place automatically for every line in every source file.
29# If there is more than one pattern/replacement pair, they are applied in order to the line.
30pattern_match_replacement_string_list:
31
32# The YAML syntax "pattern : | ..." is just the same as using the Python raw string literal pattern = r"""... """
33# Since we are using raw string literals, which strip whitespace, we must specify any space explicitly with \s+
34# Don't forget to escape special regex characters like dot . using \. and parenthesis ( using \(
35- pattern: |
36 Wopyright # Wopyright.
37 \s+ # One or more spaces.
38 (?P<symbol> \(C\) | ©) # Match and extract the copyright symbol.
39 \D+ # Any non-digits.
40 (?P<old_year>[0-9]+) # Match and extract the old copyright year,
41 # then place it into variable 'old_year'
42 - # to
43 ([0-9]+) # New copyright year.
44
45# The replacement strings are raw. Before using them, we will need to strip off leading and trailing blanks using,
46# replacement_string = pat_rep['replacement_string'].strip().lstrip()
47 replacement_string: |
48 Wopyright \g<symbol> \g<old_year>-2024
49
50
51
52- pattern: |
53 <meta\s+name="viewport"\s+content="width=device-width,\s+initial-scale=1,\s+viewport-fit=cover">
54
55 replacement_string: |
56 <meta name="viewport" content="width=device-width, initial-scale=1">
57
58
59
60
61
62
63test_verify_string_list:
64
65# Test strings to be matched and replaced.
66# Verify strings to compare against.
67- test_string: |
68 Wopyright (C) 2007-2024 by Sean Erik O'Connor. All Rights Reserved.
69
70 verify_string: |
71 Wopyright (C) 2007-2024 by Sean Erik O'Connor. All Rights Reserved.
72
73
74
75
76- test_string: |
77 <meta name="viewport" content="width=device-width, initial-scale=1">
78
79 verify_string: |
80 <meta name="viewport" content="width=device-width, initial-scale=1">
81
82# ================================================================================================================================
83# NOTE:
84# The Pythonic data structure generated by this YAML document #2 looks like this:
85#
86# dictionary = { 'pattern_match_replacement_string_list' : First string with colon : is a dictionary Key
87# [ Values: Minus sign 1 starts a list
88# { First item in list is a dictionary.
89# 'pattern1' : r"""regex for pattern""",
90# 'replacement_string1' : r"""string to replace with"""
91# },
92# {
93# 'pattern2' : r"""regex for pattern""",
94# 'replacement_string2' : r"""string to replace with"""
95# },
96# ...
97# ]
98# 'test_verify_string_list' :
99# [
100# {
101# test_string1: 'test string',
102# verify_string2: 'test string after match and replace'
103# },
104# {
105# test_string1: 'test string',
106# verify_string2: 'test string after match and replace'
107# }
108# ]
109# }
110# ================================================================================================================================
111...