-
Notifications
You must be signed in to change notification settings - Fork 0
/
CV_generator.py
42 lines (31 loc) · 1.49 KB
/
CV_generator.py
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
import os
import subprocess
import json
# Constants
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
SCRIPT_TO_RUN = os.path.join(BASE_PATH, '_DOCX_generator.py')
# Constants
# Constant for the setup configuration file path
SETUP_CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'JSON/setup.json')
def load_json_file(file_path):
"""Load JSON file from the given path."""
with open(file_path, 'r', encoding='utf-8') as file:
print(f"Loading JSON from {file_path}")
return json.load(file)
# Load configuration from setup.json
config = load_json_file(SETUP_CONFIG_PATH)
# Use the configuration values
LANGUAGE = config['LANGUAGE']
# Constructing paths based on selected language
MY_DATA_JSON_PATH = os.path.join(BASE_PATH, f'JSON/ME/LANGUAGES/{LANGUAGE}/my_data.json')
CV_DATA_JSON_PATH = os.path.join(BASE_PATH, f'JSON/CV/LANGUAGES/{LANGUAGE}/cv_data.json')
FORMAT_JSON_PATH = os.path.join(BASE_PATH, f'JSON/CV/LANGUAGES/{LANGUAGE}/cv_format.json')
PDF_SCRIPT_TO_RUN = os.path.join(BASE_PATH, '_DOCXS_to_PDF_covertor.py')
# Get name
my_data = load_json_file(MY_DATA_JSON_PATH)
name = my_data['contact_info']['name']
OUTPUT_DOCX_PATH = os.path.join(BASE_PATH, f'RESULTS/CV/CV_{name} [{LANGUAGE}].docx')
# Call the script with the new arguments
subprocess.call(["python", SCRIPT_TO_RUN, "cv=" + CV_DATA_JSON_PATH, "me=" + MY_DATA_JSON_PATH, FORMAT_JSON_PATH, OUTPUT_DOCX_PATH])
# Convert DOCX to PDF
subprocess.call(["python", PDF_SCRIPT_TO_RUN, OUTPUT_DOCX_PATH])