From 0cc96db78e050bdc29a5a068ce6d72c116343380 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Tue, 3 Dec 2019 17:19:44 -0600 Subject: [PATCH 01/26] Forced re-encoding of text to UTF-8, to avoid issues on Windows --- bin/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/util.py b/bin/util.py index f9dc12f3..084d5f46 100644 --- a/bin/util.py +++ b/bin/util.py @@ -118,6 +118,7 @@ def read_markdown(parser, path): cmd = 'ruby {0}'.format(parser) p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True, universal_newlines=True) + body = str(body.encode('utf-8')) stdout_data, stderr_data = p.communicate(body) doc = json.loads(stdout_data) From 85660470b8bc1928b941430b0667b24203cc3be8 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Tue, 3 Dec 2019 17:20:12 -0600 Subject: [PATCH 02/26] Refactored paths to make use of OS agnostic methods --- bin/lesson_check.py | 56 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 2597da5b..f7e037a8 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Check lesson files and their contents. @@ -29,19 +29,19 @@ # specially. This list must include all the Markdown files listed in the # 'bin/initialize' script. REQUIRED_FILES = { - '%/CODE_OF_CONDUCT.md': True, - '%/CONTRIBUTING.md': False, - '%/LICENSE.md': True, - '%/README.md': False, - '%/_extras/discuss.md': True, - '%/_extras/guide.md': True, - '%/index.md': True, - '%/reference.md': True, - '%/setup.md': True, + 'CODE_OF_CONDUCT.md': True, + 'CONTRIBUTING.md': False, + 'LICENSE.md': True, + 'README.md': False, + os.path.join('_extras', 'discuss.md'): True, + os.path.join('_extras', 'guide.md'): True, + 'index.md': True, + 'reference.md': True, + 'setup.md': True, } # Episode filename pattern. -P_EPISODE_FILENAME = re.compile(r'/_episodes/(\d\d)-[-\w]+.md$') +P_EPISODE_FILENAME = re.compile(r'(\d\d)-[-\w]+.md$') # Pattern to match lines ending with whitespace. P_TRAILING_WHITESPACE = re.compile(r'\s+$') @@ -117,7 +117,6 @@ def main(): check_config(args.reporter, args.source_dir) check_source_rmd(args.reporter, args.source_dir, args.parser) args.references = read_references(args.reporter, args.reference_path) - docs = read_all_markdown(args.source_dir, args.parser) check_fileset(args.source_dir, args.reporter, list(docs.keys())) check_unwanted_files(args.source_dir, args.reporter) @@ -157,7 +156,7 @@ def parse_args(): dest='trailing_whitespace', help='Check for trailing whitespace') parser.add_argument('--permissive', - default=False, + default=True, action="store_true", dest='permissive', help='Do not raise an error even if issues are detected') @@ -257,37 +256,56 @@ def read_all_markdown(source_dir, parser): {path : {'metadata':yaml, 'metadata_len':N, 'text':text, 'lines':[(i, line, len)], 'doc':doc}} """ + result = {} + for d in SOURCE_DIRS: + dpath = os.path.join(source_dir, d) + + pattern = os.path.join(dpath, '*.md') + for filename in glob.glob(pattern): + data = read_markdown(parser, filename) + if data: + result[filename] = data + + return result + all_dirs = [os.path.join(source_dir, d) for d in SOURCE_DIRS] + print(all_dirs) all_patterns = [os.path.join(d, '*.md') for d in all_dirs] + print(all_patterns) result = {} for pat in all_patterns: + print(pat) for filename in glob.glob(pat): data = read_markdown(parser, filename) if data: + print(filename) result[filename] = data - return result +# return result def check_fileset(source_dir, reporter, filenames_present): """Are all required files present? Are extraneous files present?""" # Check files with predictable names. - required = [p.replace('%', source_dir) for p in REQUIRED_FILES] + required = [os.path.join(source_dir, p) for p in REQUIRED_FILES] missing = set(required) - set(filenames_present) for m in missing: reporter.add(None, 'Missing required file {0}', m) # Check episode files' names. seen = [] - for filename in filenames_present: - if '_episodes' not in filename: + for filepath in filenames_present: + if '_episodes' not in filepath: continue - m = P_EPISODE_FILENAME.search(filename) + + # split path to check episode name + fname = os.path.basename(filepath) + m = P_EPISODE_FILENAME.search(fname) if m and m.group(1): seen.append(m.group(1)) else: reporter.add( - None, 'Episode {0} has badly-formatted filename', filename) + None, 'Episode {0} has badly-formatted filename', filepath) # Check for duplicate episode numbers. reporter.check(len(seen) == len(set(seen)), From d88b22af656c7d2c119bd7c4336136cc62d5bd5a Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Tue, 3 Dec 2019 17:20:32 -0600 Subject: [PATCH 03/26] Modified shebang to use python, not python3. --- bin/lesson_initialize.py | 2 +- bin/repo_check.py | 2 +- bin/test_lesson_check.py | 2 +- bin/workshop_check.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index 9ba81162..f798a6ed 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """Initialize a newly-created repository.""" diff --git a/bin/repo_check.py b/bin/repo_check.py index af4b7823..770ccbb8 100755 --- a/bin/repo_check.py +++ b/bin/repo_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Check repository settings. diff --git a/bin/test_lesson_check.py b/bin/test_lesson_check.py index 960059e8..899d0295 100755 --- a/bin/test_lesson_check.py +++ b/bin/test_lesson_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python import unittest diff --git a/bin/workshop_check.py b/bin/workshop_check.py index 0523d0c2..c409b896 100755 --- a/bin/workshop_check.py +++ b/bin/workshop_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python '''Check that a workshop's index.html metadata is valid. See the docstrings on the checking functions for a summary of the checks. From 21a979bd3efbfeb5b4d54a316bcb3d419b1f7b23 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Tue, 3 Dec 2019 17:23:09 -0600 Subject: [PATCH 04/26] Reverted change of permissiveness on lesson_check --- bin/lesson_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index f7e037a8..887cfa34 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -156,7 +156,7 @@ def parse_args(): dest='trailing_whitespace', help='Check for trailing whitespace') parser.add_argument('--permissive', - default=True, + default=False, action="store_true", dest='permissive', help='Do not raise an error even if issues are detected') From 901c574eaed6e0779f99baadbf1ab8466c2fff4c Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Wed, 4 Dec 2019 14:15:05 -0600 Subject: [PATCH 05/26] Cleaned leftover debug code and old implementations. --- bin/lesson_check.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 887cfa34..bc585d24 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -117,6 +117,7 @@ def main(): check_config(args.reporter, args.source_dir) check_source_rmd(args.reporter, args.source_dir, args.parser) args.references = read_references(args.reporter, args.reference_path) + docs = read_all_markdown(args.source_dir, args.parser) check_fileset(args.source_dir, args.reporter, list(docs.keys())) check_unwanted_files(args.source_dir, args.reporter) @@ -268,20 +269,6 @@ def read_all_markdown(source_dir, parser): return result - all_dirs = [os.path.join(source_dir, d) for d in SOURCE_DIRS] - print(all_dirs) - all_patterns = [os.path.join(d, '*.md') for d in all_dirs] - print(all_patterns) - result = {} - for pat in all_patterns: - print(pat) - for filename in glob.glob(pat): - data = read_markdown(parser, filename) - if data: - print(filename) - result[filename] = data -# return result - def check_fileset(source_dir, reporter, filenames_present): """Are all required files present? Are extraneous files present?""" From 82dd7fbfdec9a99121b892667211b11e5b31b643 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Wed, 4 Dec 2019 16:43:59 -0600 Subject: [PATCH 06/26] Added PYTHON variable to define executable to run python scripts --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d291abe6..8fc7d806 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ JEKYLL=jekyll JEKYLL_VERSION=3.8.5 PARSER=bin/markdown_ast.rb DST=_site +PYTHON=python3 # Controls .PHONY : commands clean files @@ -54,7 +55,7 @@ clean-rmd : ## workshop-check : check workshop homepage. workshop-check : - @bin/workshop_check.py . + ${PYTHON} bin/workshop_check.py . ## ---------------------------------------- ## Commands specific to lesson websites. @@ -93,15 +94,15 @@ _episodes/%.md: _episodes_rmd/%.Rmd ## lesson-check : validate lesson Markdown. lesson-check : lesson-fixme - @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md + ${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace. lesson-check-all : - @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive + ${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive ## unittest : run unit tests on checking tools. unittest : - @bin/test_lesson_check.py + ${PYTHON} bin/test_lesson_check.py ## lesson-files : show expected names of generated files for debugging. lesson-files : From c9add9b04978e7ba6b617d0572ab09426d6e9796 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Wed, 4 Dec 2019 16:45:02 -0600 Subject: [PATCH 07/26] Reverted variable names --- bin/lesson_check.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index bc585d24..4a4af321 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -281,18 +281,18 @@ def check_fileset(source_dir, reporter, filenames_present): # Check episode files' names. seen = [] - for filepath in filenames_present: - if '_episodes' not in filepath: + for filename in filenames_present: + if '_episodes' not in filename: continue # split path to check episode name - fname = os.path.basename(filepath) - m = P_EPISODE_FILENAME.search(fname) + base_name = os.path.basename(filename) + m = P_EPISODE_FILENAME.search(base_name) if m and m.group(1): seen.append(m.group(1)) else: reporter.add( - None, 'Episode {0} has badly-formatted filename', filepath) + None, 'Episode {0} has badly-formatted filename', filename) # Check for duplicate episode numbers. reporter.check(len(seen) == len(set(seen)), From a2d1a1f28184982d145297fb0183b9571e75352a Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Wed, 4 Dec 2019 16:45:44 -0600 Subject: [PATCH 08/26] Removed shebang lines from Python scripts to avoid cross-OS problems --- bin/lesson_check.py | 2 -- bin/lesson_initialize.py | 2 -- bin/repo_check.py | 2 -- bin/test_lesson_check.py | 2 -- bin/workshop_check.py | 2 -- 5 files changed, 10 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 4a4af321..7d135dce 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ Check lesson files and their contents. """ diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index f798a6ed..5d0488d8 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """Initialize a newly-created repository.""" diff --git a/bin/repo_check.py b/bin/repo_check.py index 770ccbb8..51d2fe0f 100755 --- a/bin/repo_check.py +++ b/bin/repo_check.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ Check repository settings. """ diff --git a/bin/test_lesson_check.py b/bin/test_lesson_check.py index 899d0295..10048b1e 100755 --- a/bin/test_lesson_check.py +++ b/bin/test_lesson_check.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - import unittest import lesson_check diff --git a/bin/workshop_check.py b/bin/workshop_check.py index c409b896..2caf5603 100755 --- a/bin/workshop_check.py +++ b/bin/workshop_check.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - '''Check that a workshop's index.html metadata is valid. See the docstrings on the checking functions for a summary of the checks. ''' From cd41c7b84eac8058677df8c3406a26aa8e0c6249 Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Thu, 5 Dec 2019 06:47:00 -0600 Subject: [PATCH 09/26] Fixes encoding problem on Windows systems, with minimal changes to existing code. --- bin/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/util.py b/bin/util.py index 084d5f46..977c4e71 100644 --- a/bin/util.py +++ b/bin/util.py @@ -117,8 +117,8 @@ def read_markdown(parser, path): # Parse Markdown. cmd = 'ruby {0}'.format(parser) p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, - close_fds=True, universal_newlines=True) - body = str(body.encode('utf-8')) + close_fds=True, universal_newlines=True, encoding='utf-8') + stdout_data, stderr_data = p.communicate(body) doc = json.loads(stdout_data) From db22e7bfc719e0e5a3caa8e736b2518e218f0afe Mon Sep 17 00:00:00 2001 From: Joao Rodrigues Date: Thu, 5 Dec 2019 06:50:49 -0600 Subject: [PATCH 10/26] Silenced output of PYTHON calls --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8fc7d806..89a31056 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ clean-rmd : ## workshop-check : check workshop homepage. workshop-check : - ${PYTHON} bin/workshop_check.py . + @${PYTHON} bin/workshop_check.py . ## ---------------------------------------- ## Commands specific to lesson websites. @@ -94,15 +94,15 @@ _episodes/%.md: _episodes_rmd/%.Rmd ## lesson-check : validate lesson Markdown. lesson-check : lesson-fixme - ${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md + @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace. lesson-check-all : - ${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive + @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive ## unittest : run unit tests on checking tools. unittest : - ${PYTHON} bin/test_lesson_check.py + @${PYTHON} bin/test_lesson_check.py ## lesson-files : show expected names of generated files for debugging. lesson-files : From 4381bcba70153a0ee0385ef440c7a6e2d7745536 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 10:46:38 -0600 Subject: [PATCH 11/26] Makefile: detect Python 3 --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89a31056..ecdb2309 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,21 @@ JEKYLL=jekyll JEKYLL_VERSION=3.8.5 PARSER=bin/markdown_ast.rb DST=_site -PYTHON=python3 + +# Check Python 3 (https://stackoverflow.com/a/4933395) +ifneq (, $(shell which python3)) + PYTHON := python3 +else ifneq (, $(shell which python)) + PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) + PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) + ifneq (3, ${PYTHON_VERSION_MAJOR}) + $(error "Your system does not appear to have Python 3 installed.") + endif + PYTHON := python +else + $(error "Your system does not appear to have any Python installed.") +endif + # Controls .PHONY : commands clean files From ff5f567173f6f504c4cc011b338bc4e941486f70 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 10:49:09 -0600 Subject: [PATCH 12/26] util.py: remove empty line --- bin/util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/util.py b/bin/util.py index 977c4e71..5a46cec0 100644 --- a/bin/util.py +++ b/bin/util.py @@ -118,7 +118,6 @@ def read_markdown(parser, path): cmd = 'ruby {0}'.format(parser) p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True, universal_newlines=True, encoding='utf-8') - stdout_data, stderr_data = p.communicate(body) doc = json.loads(stdout_data) From a61b7f63ee2694b4ef7494f88bb864ab05576869 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 13:36:50 -0600 Subject: [PATCH 13/26] Undo optimizations to read_all_markdown These will be submitted in a separate PR --- bin/lesson_check.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 7d135dce..d9cc7a70 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -255,16 +255,14 @@ def read_all_markdown(source_dir, parser): {path : {'metadata':yaml, 'metadata_len':N, 'text':text, 'lines':[(i, line, len)], 'doc':doc}} """ + all_dirs = [os.path.join(source_dir, d) for d in SOURCE_DIRS] + all_patterns = [os.path.join(d, '*.md') for d in all_dirs] result = {} - for d in SOURCE_DIRS: - dpath = os.path.join(source_dir, d) - - pattern = os.path.join(dpath, '*.md') - for filename in glob.glob(pattern): + for pat in all_patterns: + for filename in glob.glob(pat): data = read_markdown(parser, filename) if data: result[filename] = data - return result From bab0fcab35a5e279a539d51b48abc24854deb98e Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 13:37:44 -0600 Subject: [PATCH 14/26] Remove executable bits from Python scripts We can't use a single shebang: * on some platforms `python` may mean Python 2, on others - Python 3 * on some platforms `python3` does not exist at all Therefore, we're removing the shebangs altogether. --- bin/lesson_check.py | 0 bin/lesson_initialize.py | 0 bin/repo_check.py | 0 bin/test_lesson_check.py | 0 bin/workshop_check.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bin/lesson_check.py mode change 100755 => 100644 bin/lesson_initialize.py mode change 100755 => 100644 bin/repo_check.py mode change 100755 => 100644 bin/test_lesson_check.py mode change 100755 => 100644 bin/workshop_check.py diff --git a/bin/lesson_check.py b/bin/lesson_check.py old mode 100755 new mode 100644 diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py old mode 100755 new mode 100644 diff --git a/bin/repo_check.py b/bin/repo_check.py old mode 100755 new mode 100644 diff --git a/bin/test_lesson_check.py b/bin/test_lesson_check.py old mode 100755 new mode 100644 diff --git a/bin/workshop_check.py b/bin/workshop_check.py old mode 100755 new mode 100644 From bce2366e8f96bc043ff3a8f9a28ac666c701e7e2 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 14:13:05 -0600 Subject: [PATCH 15/26] lesson_initialize: windows compatibility --- bin/lesson_initialize.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index 5d0488d8..1ac8a232 100644 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -12,11 +12,11 @@ 'CONTRIBUTING.md', 'README.md', '_config.yml', - '_episodes/01-introduction.md', - '_extras/about.md', - '_extras/discuss.md', - '_extras/figures.md', - '_extras/guide.md', + os.path.join('_episodes', '01-introduction.md'), + os.path.join('_extras', 'about.md'), + os.path.join('_extras', 'discuss.md'), + os.path.join('_extras', 'figures.md'), + os.path.join('_extras', 'guide.md'), 'index.md', 'reference.md', 'setup.md', @@ -39,7 +39,7 @@ def main(): # Create. for path in BOILERPLATE: shutil.copyfile( - "bin/boilerplate/{}".format(path), + os.path.join('bin', 'boilerplate', path) path ) From 1a0adfdeb4048bea419c1b0d3bc0bffd5bf89922 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 15:20:52 -0600 Subject: [PATCH 16/26] lesson_check.py: Windows-compatible regular expression pattern --- bin/lesson_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index d9cc7a70..ee84d849 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -557,7 +557,7 @@ def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): (re.compile(r'README\.md'), CheckNonJekyll), (re.compile(r'index\.md'), CheckIndex), (re.compile(r'reference\.md'), CheckReference), - (re.compile(r'_episodes/.*\.md'), CheckEpisode), + (re.compile(os.path.join('_episodes', '*\.md')), CheckEpisode), (re.compile(r'.*\.md'), CheckGeneric) ] From ec294aabfb5a26f14e2890e77662ba125eab7411 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 15:36:51 -0600 Subject: [PATCH 17/26] repo_check.py: enforce utf-8 encoding ... for compatibility with Windows --- bin/repo_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/repo_check.py b/bin/repo_check.py index 51d2fe0f..31651fd2 100644 --- a/bin/repo_check.py +++ b/bin/repo_check.py @@ -102,7 +102,7 @@ def get_repo_url(repo_url): # Guess. cmd = 'git remote -v' p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, - close_fds=True, universal_newlines=True) + close_fds=True, universal_newlines=True, encoding='utf-8') stdout_data, stderr_data = p.communicate() stdout_data = stdout_data.split('\n') matches = [P_GIT_REMOTE.match(line) for line in stdout_data] From caf3b88f6baf62fca1cabacfe78931f5e0031f93 Mon Sep 17 00:00:00 2001 From: Sarah Brown Date: Fri, 6 Dec 2019 11:53:29 -0500 Subject: [PATCH 18/26] clarify comment on python check block --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ecdb2309..dd472031 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ JEKYLL_VERSION=3.8.5 PARSER=bin/markdown_ast.rb DST=_site -# Check Python 3 (https://stackoverflow.com/a/4933395) +# Check Python 3 is installed and determine if it's called via python3 or python +# (https://stackoverflow.com/a/4933395) ifneq (, $(shell which python3)) PYTHON := python3 else ifneq (, $(shell which python)) From d454d5916a5271ec645b219fbdf6e925db187b9f Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 6 Dec 2019 13:31:19 -0600 Subject: [PATCH 19/26] Makefile: Windows does not like single quotes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dd472031..a4268d71 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ all : commands ## commands : show all commands. commands : - @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g' + @grep -h -E '^##' ${MAKEFILES} | sed -e "s/## //g" ## docker-serve : use docker to build the site docker-serve : From 41605eb72f086f2f31766e1ca96d43850f625c65 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 6 Dec 2019 13:31:55 -0600 Subject: [PATCH 20/26] test_lesson_check.py: skip unnecessary steps --- bin/test_lesson_check.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/test_lesson_check.py b/bin/test_lesson_check.py index 10048b1e..0981720a 100644 --- a/bin/test_lesson_check.py +++ b/bin/test_lesson_check.py @@ -10,10 +10,8 @@ def setUp(self): def test_file_list_has_expected_entries(self): # For first pass, simply assume that all required files are present - all_filenames = [filename.replace('%', '') - for filename in lesson_check.REQUIRED_FILES] - lesson_check.check_fileset('', self.reporter, all_filenames) + lesson_check.check_fileset('', self.reporter, lesson_check.REQUIRED_FILES) self.assertEqual(len(self.reporter.messages), 0) From 651af34cbeccbf8a159320a75ce43f30bf88a753 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 6 Dec 2019 13:43:11 -0600 Subject: [PATCH 21/26] Makefile: suppress error message on Windows --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a4268d71..4daaae66 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ DST=_site # Check Python 3 is installed and determine if it's called via python3 or python # (https://stackoverflow.com/a/4933395) -ifneq (, $(shell which python3)) +ifneq (, $(shell which python3 2>/dev/null)) PYTHON := python3 else ifneq (, $(shell which python)) PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) From 8eb0425e98fa8b42f3d628ab712e029c77a18a15 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 6 Dec 2019 14:20:31 -0600 Subject: [PATCH 22/26] fix typo in lesson_initialize.py --- bin/lesson_initialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index 1ac8a232..2f7b8e67 100644 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -39,7 +39,7 @@ def main(): # Create. for path in BOILERPLATE: shutil.copyfile( - os.path.join('bin', 'boilerplate', path) + os.path.join('bin', 'boilerplate', path), path ) From ecb16113fc647b59cb3ee4d66bfc717fdb755444 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 6 Dec 2019 15:11:48 -0600 Subject: [PATCH 23/26] Makefile: suppress another error message on Windows These '2>/dev/null' are important on Windows because without them a mere `make` stalls. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4daaae66..ba5080ad 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DST=_site # (https://stackoverflow.com/a/4933395) ifneq (, $(shell which python3 2>/dev/null)) PYTHON := python3 -else ifneq (, $(shell which python)) +else ifneq (, $(shell which python 2>/dev/null)) PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) ifneq (3, ${PYTHON_VERSION_MAJOR}) From e6622b88a854224eb6e6a6b118c000f0bcc12736 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 9 Dec 2019 16:45:16 -0600 Subject: [PATCH 24/26] Makefile: handle MS Store's Python 3 --- Makefile | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ba5080ad..a0cad9ee 100644 --- a/Makefile +++ b/Makefile @@ -10,17 +10,25 @@ DST=_site # Check Python 3 is installed and determine if it's called via python3 or python # (https://stackoverflow.com/a/4933395) -ifneq (, $(shell which python3 2>/dev/null)) - PYTHON := python3 -else ifneq (, $(shell which python 2>/dev/null)) - PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) - PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) - ifneq (3, ${PYTHON_VERSION_MAJOR}) - $(error "Your system does not appear to have Python 3 installed.") +PYTHON3_EXE := $(shell which python3 2>/dev/null) +ifneq (, $(PYTHON3_EXE)) + ifeq $(,findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))) + PYTHON := python3 + endif +endif + +ifeq $(,$(PYTHON)) + PYTHON_EXE := $(shell which python 2>/dev/null) + ifneq (, $(PYTHON_EXE)) + PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) + PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) + ifneq (3, ${PYTHON_VERSION_MAJOR}) + $(error "Your system does not appear to have Python 3 installed.") + endif + PYTHON := python + else + $(error "Your system does not appear to have any Python installed.") endif - PYTHON := python -else - $(error "Your system does not appear to have any Python installed.") endif From a732a2b2e6f9db3632d8c6a58eeb985b5fd12b26 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 9 Dec 2019 16:51:12 -0600 Subject: [PATCH 25/26] Makefile: fix syntax in conditional --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a0cad9ee..f4f44d04 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DST=_site # (https://stackoverflow.com/a/4933395) PYTHON3_EXE := $(shell which python3 2>/dev/null) ifneq (, $(PYTHON3_EXE)) - ifeq $(,findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))) + ifeq $(,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE)))) PYTHON := python3 endif endif From f1cb887d2083f05ae570cb44d7615c3b6cb9f913 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 9 Dec 2019 16:55:00 -0600 Subject: [PATCH 26/26] Makefile: fix two more syntax errors in conditionals --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f4f44d04..5ae969f6 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,12 @@ DST=_site # (https://stackoverflow.com/a/4933395) PYTHON3_EXE := $(shell which python3 2>/dev/null) ifneq (, $(PYTHON3_EXE)) - ifeq $(,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE)))) + ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE)))) PYTHON := python3 endif endif -ifeq $(,$(PYTHON)) +ifeq (,$(PYTHON)) PYTHON_EXE := $(shell which python 2>/dev/null) ifneq (, $(PYTHON_EXE)) PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))