-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
parse_data.sh
77 lines (65 loc) · 2.11 KB
/
parse_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
WORKING_FOLDER_NAME=tmp
ARCHIVE_NAME=data_downloaded.zip
ZIP_ARCHIVE_PATH=./$WORKING_FOLDER_NAME/$ARCHIVE_NAME
JSON_PREFIX=combined
JSON_SUFFIX=.json
DESTINATION_PATH=./timezonefinder
URL_PREFIX=https://github.com/evansiroky/timezone-boundary-builder/releases/latest/download/timezones
URL_SUFFIX=.geojson.zip
echo "TIME ZONE DATA PARSING SCRIPT"
# make script work independent of where you invoke it from
parent_path=$(
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
pwd -P
)
cd "$parent_path" || exit 1
mkdir -p "$WORKING_FOLDER_NAME" # if does not exist
echo "use timezone data with oceans (0: No, 1: Yes)? "
read -r WITH_OCEANS
if [ "$WITH_OCEANS" -eq 1 ]; then
INTERFIX=-with-oceans
else
INTERFIX=""
fi
JSON_FILE_NAME=$JSON_PREFIX$INTERFIX$JSON_SUFFIX
JSON_PATH=./$WORKING_FOLDER_NAME/$JSON_FILE_NAME
if [ -f $JSON_PATH ]; then
echo "skip unpacking: $JSON_PATH already exists."
else
if [ -f $ZIP_ARCHIVE_PATH ]; then
echo "skipping download: $ZIP_ARCHIVE_PATH already exists."
else
URL=$URL_PREFIX$INTERFIX$URL_SUFFIX
echo "DOWNLOADING $URL"
# install command mac:
# brew install wget
wget -O $ZIP_ARCHIVE_PATH $URL --tries=3
fi
echo "UNPACKING..."
unzip $ZIP_ARCHIVE_PATH -d $WORKING_FOLDER_NAME
fi
echo "START PARSING..."
SCRIPT_PATH=./scripts/file_converter.py
echo "calling $SCRIPT_PATH:"
python "$SCRIPT_PATH" -inp "$JSON_PATH" -out "$DESTINATION_PATH"
echo "runnings tests..."
if ! tox; then
# assert that all tests are passing
echo "tests failed!"
exit 1
fi
# minor version bump
poetry version minor
# TODO
read -r -p "should all temporary data files be deleted (0: No, 1: Yes)?" do_deletion
if [ "$do_deletion" -eq 1 ]; then
rm -r "$WORKING_FOLDER_NAME"
fi
# TODO add changelog entry: keep title, current date, parse data version
# $(poetry version) (2022-12-06)
#------------------
#
#* updated the data to `2022g <https://github.com/evansiroky/timezone-boundary-builder/releases/tag/2022g>`__.
#echo -e "DATA-Line-1\n$(cat input)" > input
echo "SUCCESS! the new package version $(poetry version) can now be released!"