Skip to content

Commit

Permalink
json2giggity.py: Automatically try to run ampersand.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
primeos committed Jun 20, 2019
1 parent e86ede7 commit 1907727
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions 2019/giggity.xml
Expand Up @@ -1297,6 +1297,8 @@ Grundverständnis von Programmiersprachen
</description>
<persons><person>Peter Hrenka</person></persons>
<links>
- <link href="https://minecraft.gamepedia.com/Minecraft_Wiki">Minecraft Wiki</link>
- <link href="https://github.com/MinecraftForge/MinecraftForge">Minecraft Forge</link>
- <link href="https://www.minecraft.net/de-de">Offizielle Seite</link>
</links>
</event>
Expand Down
7 changes: 5 additions & 2 deletions bin/ampersand.sh
@@ -1,7 +1,10 @@
#!/bin/bash -x
#!/usr/bin/env bash

set -o errexit
set -o xtrace

# ampersand
perl -p -i -e 's/ & / &#x26; /g' giggity.xml
perl -p -i -e 's/next&id/next&#x26;id/g' giggity.xml

xmllint giggity.xml
xmllint giggity.xml --noout
16 changes: 14 additions & 2 deletions bin/json2giggity.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

import json
import os
import subprocess
import sys
import io

Expand All @@ -15,10 +17,10 @@ def parse_weblink(weblinks):
return "\n".join(link_list)


def giggitytimes(minutes):
def giggitytimes(minutes):
hour = minutes // 60
minutes = minutes % 60
return "%02d:%02d" % (hour, minutes)
return "%02d:%02d" % (hour, minutes)


with io.open('talks.json', 'r', encoding='utf8') as talksfile:
Expand Down Expand Up @@ -53,3 +55,13 @@ def giggitytimes(minutes):
gigxml.write('</event>\n\n')
gigxml.write('</room>\n')
gigxml.write('</day>\n</schedule>')

# Try to automatically run ampersand.sh:
AMPERSAND_FILE = "../bin/ampersand.sh"
if os.path.isfile(AMPERSAND_FILE):
try:
subprocess.run(["nix", "--version"], stdout=subprocess.DEVNULL)
# Nix is available:
os.system("nix-shell -p libxml2 --run " + AMPERSAND_FILE)
except FileNotFoundError:
os.system(AMPERSAND_FILE)

0 comments on commit 1907727

Please sign in to comment.