Skip to content

Commit

Permalink
info: Don't auto-create dirs on import
Browse files Browse the repository at this point in the history
- The directory-creation code is moved to info.setup_userdirs(),
  called by launch.py before creating the OpenShotApp instance
- app.mode is now set by keyword-only argument, and is no longer
  passed to MainWindow() (as the GUI is never started in unit test
  mode).
- Removed all references to window.mode from the GUI code

Co-authored-by: Jackson <jackson@openshot.org>
  • Loading branch information
ferdnyc and Jackson committed Dec 9, 2021
1 parent 0e3b6ef commit 7a46a90
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/classes/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
except ImportError:
language_path = os.path.join(PATH, 'language')
print("Compiled translation resources missing!")
print("Loading translations from: {}".format(language_path))
print(f"Loading translations from: {language_path}")

# Compile language list from :/locale resource
try:
Expand Down Expand Up @@ -192,13 +192,7 @@
def setup_userdirs():
"""Create user paths if they do not exist (this is where
temp files are stored... such as cached thumbnails)"""
for folder in [
USER_PATH, BACKUP_PATH, RECOVERY_PATH, THUMBNAIL_PATH,
CACHE_PATH, BLENDER_PATH, TITLE_PATH, TRANSITIONS_PATH,
PREVIEW_CACHE_PATH, USER_PROFILES_PATH, USER_PRESETS_PATH,
USER_TITLES_PATH, EMOJIS_PATH, PROTOBUF_DATA_PATH,
YOLO_PATH,
]:
for folder in _path_defaults.values():
if not os.path.exists(os.fsencode(folder)):
os.makedirs(folder, exist_ok=True)

Expand All @@ -211,6 +205,20 @@ def setup_userdirs():
os.rename(LEGACY_DEFAULT_PROJECT, USER_DEFAULT_PROJECT)


def reset_userdirs():
"""Reset all info.FOO_PATH attributes back to their initial values,
as they may have been modified by the runtime code (retargeting
info.THUMBNAIL_PATH to a project assets directory, for example)"""
for k, v in _path_defaults.items():
globals()[k] = v


def get_default_path(varname):
"""Return the default value of the named info.FOO_PATH attribute,
even if it's been modified"""
return _path_defaults.get(varname, None)


def website_language():
"""Get the current website language code for URLs"""
return {
Expand Down

0 comments on commit 7a46a90

Please sign in to comment.