forked from jpetazzo/container.training
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade slide generator to python3; generate a zip file too
- Loading branch information
Showing
6 changed files
with
30 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM alpine:3.9 | ||
RUN apk add --no-cache entr py-pip git | ||
FROM alpine:3.11 | ||
RUN apk add --no-cache entr py3-pip git zip | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
RUN pip3 install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env python2 | ||
#!/usr/bin/env python3 | ||
# transforms a YAML manifest into a HTML workshop file | ||
|
||
import glob | ||
|
@@ -20,12 +20,19 @@ def anchor(title): | |
return "toc-" + title | ||
|
||
|
||
def interstitials_generator(): | ||
images = [url.strip() for url in open("interstitials.txt") if url.strip()] | ||
while True: | ||
for image in images: | ||
yield image | ||
interstitials = interstitials_generator() | ||
class Interstitials(object): | ||
|
||
def __init__(self): | ||
self.index = 0 | ||
self.images = [url.strip() for url in open("interstitials.txt") if url.strip()] | ||
|
||
def next(self): | ||
index = self.index % len(self.images) | ||
index += 1 | ||
return self.images[index] | ||
|
||
|
||
interstitials = Interstitials() | ||
|
||
|
||
def insertslide(markdown, title): | ||
|
@@ -154,8 +161,6 @@ def gentoc(tree, path=()): | |
# Returns: (epxandedmarkdown,[list of titles]) | ||
# The list of titles can be nested. | ||
def processchapter(chapter, filename): | ||
if isinstance(chapter, unicode): | ||
return processchapter(chapter.encode("utf-8"), filename) | ||
if isinstance(chapter, str): | ||
if "\n" in chapter: | ||
titles = re.findall("^# (.*)", chapter, re.MULTILINE) | ||
|
@@ -179,27 +184,27 @@ def processchapter(chapter, filename): | |
if "REPOSITORY_URL" in os.environ: | ||
repo = os.environ["REPOSITORY_URL"] | ||
else: | ||
repo = subprocess.check_output(["git", "config", "remote.origin.url"]) | ||
repo = subprocess.check_output(["git", "config", "remote.origin.url"]).decode("ascii") | ||
repo = repo.strip().replace("[email protected]:", "https://github.com/") | ||
if "BRANCH" in os.environ: | ||
branch = os.environ["BRANCH"] | ||
else: | ||
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]) | ||
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode("ascii") | ||
branch = branch.strip() | ||
base = subprocess.check_output(["git", "rev-parse", "--show-prefix"]) | ||
base = subprocess.check_output(["git", "rev-parse", "--show-prefix"]).decode("ascii") | ||
base = base.strip().strip("/") | ||
urltemplate = ("{repo}/tree/{branch}/{base}/{filename}" | ||
.format(repo=repo, branch=branch, base=base, filename="{}")) | ||
except: | ||
logging.exception("Could not generate repository URL; generating local URLs instead.") | ||
urltemplate = "file://{pwd}/{filename}".format(pwd=os.environ["PWD"], filename="{}") | ||
try: | ||
commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) | ||
commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii") | ||
except: | ||
logging.exception("Could not figure out HEAD commit.") | ||
commit = "??????" | ||
try: | ||
dirtyfiles = subprocess.check_output(["git", "status", "--porcelain"]) | ||
dirtyfiles = subprocess.check_output(["git", "status", "--porcelain"]).decode("ascii") | ||
except: | ||
logging.exception("Could not figure out repository cleanliness.") | ||
dirtyfiles = "?? git status --porcelain failed" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.7 |