Compare commits
4 Commits
bd6360177f
...
771d8e7aca
| Author | SHA1 | Date | |
|---|---|---|---|
| 771d8e7aca | |||
| 36897255a4 | |||
| bf5aee2f00 | |||
| b4fec83039 |
@@ -1,5 +1,27 @@
|
||||
<?php
|
||||
$options = getopt("", ["input:", "output:", "media:"]);
|
||||
$options = getopt("", ["folder:", "input:", "output:", "media:"]);
|
||||
|
||||
if (isset($options['folder'])) {
|
||||
$folder = $options['folder'];
|
||||
if (is_dir($folder)) {
|
||||
$lastpart = basename($folder);
|
||||
if (!isset($options['input'])) {
|
||||
$potentialInputFile = $folder . DIRECTORY_SEPARATOR . strtoupper($lastpart) . ".csv";
|
||||
if (is_file($potentialInputFile)) {
|
||||
$options['input'] = $potentialInputFile;
|
||||
}
|
||||
}
|
||||
if (!isset($options['output'])) {
|
||||
$options['output'] = $folder . DIRECTORY_SEPARATOR . "candidates.csv";
|
||||
}
|
||||
if (!isset($options['media'])) {
|
||||
$options['media'] = $folder;
|
||||
}
|
||||
} else {
|
||||
error_log("Error: Specified folder is not valid.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['input'])) {
|
||||
$inputFile = $options['input'];
|
||||
@@ -65,7 +87,7 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
print("Adding candidate " . $candidateName . " to ". $currentWard . "\n");
|
||||
//print("Adding candidate " . $candidateName . " to ". $currentWard . "\n");
|
||||
|
||||
$name_split = explode(" ", $data[1]);
|
||||
|
||||
@@ -86,7 +108,7 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
|
||||
}
|
||||
}
|
||||
if ($picture === "") {
|
||||
print("Failed to identify picture for " . $candidateName . "\n");
|
||||
print("\033[31mFailed to identify picture for " . $candidateName . "\033[0m\n");
|
||||
}
|
||||
|
||||
$rating = $data[2];
|
||||
@@ -144,6 +166,6 @@ if (($handle = fopen($outputFile, "w")) !== FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print("Data written to " . $outputFile);
|
||||
print("Data written to " . $outputFile . "\n");
|
||||
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user