diff --git a/pdf/README.md b/pdf/README.md index 71ab9a6..dd43774 100644 --- a/pdf/README.md +++ b/pdf/README.md @@ -25,7 +25,7 @@ Printing to PDF * Open `index.html` in text editor and first remove element `
\'!r\'
calls object\'s repr() method, instead of str(), to get a string.': '\'!r\'
calls object\'s repr() method, instead of str(), to get a string (p. 14).',
+ 'Default_factory can be any callable.': 'Default_factory can be any callable (p. 17).',
+ 'Iterators returned by the iter() function, such as list_iterator and set_iterator.': 'Iterators returned by the iter() function, such as list_iterator and set_iterator (p. 3).',
+ 'Objects returned by the itertools module, such as count, repeat and cycle.': 'Objects returned by the itertools module, such as count, repeat and cycle (p. 3).',
+ 'Generators returned by the generator functions and generator expressions.': 'Generators returned by the generator functions (p. 4) and generator expressions (p. 11).',
+ 'File objects returned by the open() function, etc.': 'File objects returned by the open() function (p. 22), etc.',
+ 'Another solution in this particular case is to use built-in functions and_() and or_() from the module operator.': 'Another solution in this particular case is to use built-in functions and_() and or_() from the module operator (p. 31).',
+ 'Functions report OS related errors by raising either OSError or one of its subclasses.': 'Functions report OS related errors by raising OSError or one of its subclasses (p. 23).',
+ 'Bools will be stored and returned as ints and dates as ISO formatted strings.': 'Bools will be stored and returned as ints and dates as ISO formatted strings (p. 9).',
+ 'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes.': 'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes (p. 30).',
+}
+
+
+def main():
+ index_path = Path('..', 'index.html')
+ lines = read_file(index_path)
+ out = ''.join(lines)
+ for from_, to_ in MATCHES.items():
+ out = out.replace(from_, to_, 1)
+ write_to_file(index_path, out)
+
+
+###
+## UTIL
+#
+
+def read_file(filename):
+ p = Path(__file__).resolve().parent / filename
+ with open(p, encoding='utf-8') as file:
+ return file.readlines()
+
+
+def write_to_file(filename, text):
+ p = Path(__file__).resolve().parent / filename
+ with open(p, 'w', encoding='utf-8') as file:
+ file.write(text)
+
+
+if __name__ == '__main__':
+ main()