Completed
Push — master ( 279b7a...65d2af )
by David
49s queued 15s
created

get_buda_app_desc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
$buda_root = "../../buda_apps";
4
5
function get_buda_apps() {
6
    global $buda_root;
7
    $apps = [];
8
    $x = scandir($buda_root);
9
    foreach ($x as $app) {
10
        if ($app[0] == '.') continue;
11
        if (!is_dir("$buda_root/$app")) continue;
12
        $apps[] = $app;
13
    }
14
    return $apps;
15
}
16
17
// return list of variant dir names
18
//
19
function get_buda_variants($app_name) {
20
    global $buda_root;
21
    $x = [];
22
    $app_dir = "$buda_root/$app_name";
23
    $dirs = scandir($app_dir);
24
    foreach ($dirs as $dir) {
25
        if ($dir[0] == '.') continue;
26
        if (!is_dir("$app_dir/$dir")) continue;
27
        $x[] = $dir;
28
    }
29
    return $x;
30
}
31
32
function get_buda_app_desc($app) {
33
    global $buda_root;
34
    $path = "$buda_root/$app/desc.json";
35
    return json_decode(file_get_contents($path));
36
}
37
38
function get_buda_var_desc($app, $var) {
39
    global $buda_root;
40
    $path = "$buda_root/$app/$var/variant.json";
41
    return json_decode(file_get_contents($path));
42
}
43
44
function variant_name($desc) {
45
    if ($desc->plan_class) {
46
        return "$desc->cpu_type ($desc->plan_class)";
47
    } else {
48
        return "$desc->cpu_type (CPU)";
49
    }
50
}
51
52
?>
53