Make highlighter script work with python3 and log a better error than

just the exit code when the highlighter fails
This commit is contained in:
Jimmy Tang 2016-12-19 13:37:36 +00:00
parent a7ea8be053
commit 4a50d1b19f
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,10 @@
#!/usr/bin/python #!/usr/bin/env python
try:
import pygments
except ImportError:
print(" Please install python pygments module")
import pygments
from pygments import highlight from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.formatters import HtmlFormatter from pygments.formatters import HtmlFormatter
@ -65,13 +69,13 @@ def usage(err=0):
def get_styles(): def get_styles():
item = pygments.styles.get_all_styles() item = pygments.styles.get_all_styles()
for items in item: for items in item:
print items print(items)
sys.exit(0) sys.exit(0)
def get_lexers(): def get_lexers():
item = pygments.lexers.get_all_lexers() item = pygments.lexers.get_all_lexers()
for items in item: for items in item:
print items[0]+";"+items[1][0] print(items[0]+";"+items[1][0])
sys.exit(0) sys.exit(0)

View File

@ -191,7 +191,7 @@ func getSupportedLangs() {
arg := "getlexers" arg := "getlexers"
out, err := exec.Command(configuration.Highlighter, arg).Output() out, err := exec.Command(configuration.Highlighter, arg).Output()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err, string(out))
} }
// Loop lexers and add them to respectively map, // Loop lexers and add them to respectively map,