|
22 | 22 | import pkg_resources |
23 | 23 | from packaging import version |
24 | 24 |
|
| 25 | +own_dir = os.path.abspath(os.path.dirname(__file__)) |
| 26 | + |
25 | 27 |
|
26 | 28 | # Set up global variables and the used classes |
27 | 29 | options = {} |
28 | | -hashes = Hashlist("./data/hashes") |
| 30 | +hashes = Hashlist(os.path.join(own_dir, "data/hashes")) |
29 | 31 | decoder = Decoder(hashes) |
30 | 32 | encoder = Encoder() |
31 | 33 | savefiles = {} |
|
35 | 37 | loaded_items = {} |
36 | 38 |
|
37 | 39 | # Load the version number of this application and already create a newversion variable for a later check for updates |
38 | | -with open("./data/version") as f: |
| 40 | +with open(os.path.join(own_dir, "data/version")) as f: |
39 | 41 | currentversion = f.read() |
40 | 42 | newversion = currentversion |
41 | 43 |
|
42 | 44 |
|
43 | 45 | # Load the information about the item version making it possible to fix bugs without having to make a new release |
44 | 46 | # (when no code was changed) |
45 | | -with open("./data/itemversion") as f: |
| 47 | +with open(os.path.join(own_dir, "data/itemversion")) as f: |
46 | 48 | currentiversion = f.read() |
47 | 49 | newiversion = currentiversion |
48 | 50 |
|
49 | 51 |
|
50 | 52 | # Load the settings of the settings file |
51 | 53 | def load_settings(): |
52 | | - with open("./data/settings") as f: |
| 54 | + with open(os.path.join("data/settings")) as f: |
53 | 55 | global options, newversion, newiversion, web_app_options |
54 | 56 | options = json.load(f) |
55 | 57 |
|
@@ -357,7 +359,7 @@ def save_json_savefile(data, shash): |
357 | 359 | # If we want to dump it as html file we do so here |
358 | 360 | if file.endswith(".html"): |
359 | 361 |
|
360 | | - with open('./data/html/dumpskeleton.html', 'r') as placeholderfile: |
| 362 | + with open(os.path.join(own_dir, 'data/html/dumpskeleton.html'), 'r') as placeholderfile: |
361 | 363 | placeholder = placeholderfile.read() |
362 | 364 |
|
363 | 365 | print("Creating HTML file at " + file) |
@@ -1035,7 +1037,7 @@ def set_settings(settings): |
1035 | 1037 | if "path" in options: |
1036 | 1038 | options["path"] = os.path.expandvars(options["path"]) |
1037 | 1039 |
|
1038 | | - with open("./data/settings", "w") as f: |
| 1040 | + with open(os.path.join(own_dir, "data/settings"), "w") as f: |
1039 | 1041 | json.dump(settings, f) |
1040 | 1042 | return True |
1041 | 1043 |
|
|
0 commit comments