diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-03-28 00:40:33 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-04-01 19:12:09 +0200 |
commit | 71f0d462f2d695acb4126adfd50f92c8b3ab8bc2 (patch) | |
tree | f8c55f2dcb5cb868d12126a1ea27b2ef39d00751 /application | |
parent | b58d6d44bda3b229c4f0a32f5147f44b0c9ec446 (diff) |
Refactor \libraries\Pygments::get_lexers
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r-- | application/libraries/Pygments.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php index ddddf40d9..ab3868087 100644 --- a/application/libraries/Pygments.php +++ b/application/libraries/Pygments.php @@ -20,14 +20,23 @@ class Pygments { $this->filename = $filename; } + private static function get_pygments_info() { + return cache_function('pygments_info', 1800, function() { + ob_start(); + passthru("python ".escapeshellarg(FCPATH."scripts/get_lexer_list.py")); + $output = ob_get_clean(); + + return json_decode($output, true); + }); + } + public static function get_lexers() { return cache_function('lexers', 1800, function() { - $lexers = array(); $last_desc = ""; - exec("python ".escapeshellarg(FCPATH."scripts/get_lexer_list.py"), $output); - foreach ($output as $line) { - list($name, $desc) = explode("|", $line); + foreach (self::get_pygments_info() as $lexer) { + $desc = $lexer['fullname']; + $name = $lexer['names'][0]; if ($desc == $last_desc) { continue; } |