Example #1
0
 def load_(self):
     try:
         self._prefs = util.get_config_yaml(self._filename)
         if not hasattr(self._prefs, "get"):
             self._prefs = self._defaults
     except FileNotFoundError:
         self._prefs = self._defaults
Example #2
0
def fix_paths_with_saved_prefix(
    filenames,
    missing: Optional[List[bool]] = None,
    path_prefix_conversions: Optional[Dict[Text, Text]] = None,
):
    if path_prefix_conversions is None:
        path_prefix_conversions = util.get_config_yaml("path_prefixes.yaml")

    if path_prefix_conversions is None:
        return

    for i, filename in enumerate(filenames):
        if missing is not None:
            if not missing[i]:
                continue
        elif os.path.exists(filename):
            continue

        for old_prefix, new_prefix in path_prefix_conversions.items():
            if filename.startswith(old_prefix):
                try_filename = filename.replace(old_prefix, new_prefix)
                try_filename = fix_path_separator(try_filename)

                if os.path.exists(try_filename):
                    filenames[i] = try_filename
                    if missing is not None:
                        missing[i] = False
                    continue
Example #3
0
 def load_(self):
     """Load preferences from file (regardless of whether loaded already)."""
     try:
         self._prefs = util.get_config_yaml(self._filename)
         if not hasattr(self._prefs, "get"):
             self._prefs = self._defaults
     except FileNotFoundError:
         self._prefs = self._defaults
Example #4
0
def save_path_prefix_replacement(old_prefix: str, new_prefix: str):
    data = util.get_config_yaml("path_prefixes.yaml") or dict()
    data[old_prefix] = new_prefix
    util.save_config_yaml("path_prefixes.yaml", data)
Example #5
0
    def __init__(self):
        shortcuts = util.get_config_yaml("shortcuts.yaml")
        defaults = util.get_config_yaml("shortcuts.yaml", get_defaults=True)

        self._shortcuts = self._process_shortcut_dict(shortcuts)
        self._defaults = self._process_shortcut_dict(defaults)
Example #6
0
 def reset_to_default(self):
     """Reset shortcuts to default and save."""
     self._shortcuts = util.get_config_yaml("shortcuts.yaml", get_defaults=True)
     self.save()