Set default config in the constant module. Use from there to configure app

- Avoid having to pass the khoj_sample.yml data file into pip, native apps
- Packaging data files into python packages is annoying.
  - There's `MANIFEST.in`, `data_files` and `package_data` in setup.py
  - Bdist, wheel, generated source tarball use different set of these fields
    and put the data files in different locations
  - Rather just code the default config into a constant. Avoid
    pointless file reads as well this way
This commit is contained in:
Debanjum Singh Solanky
2022-08-12 02:18:46 +03:00
parent 3f293a8766
commit 110e3df0b7
3 changed files with 61 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ class ConfigureScreen(QtWidgets.QDialog):
if resolve_absolute_path(self.config_file).exists():
self.current_config = yaml_utils.load_config_from_file(self.config_file)
else:
self.current_config = yaml_utils.load_config_from_file(constants.app_root_directory / 'config/khoj_sample.yml')
self.current_config = constants.default_config
self.new_config = self.current_config
# Initialize Configure Window
@@ -127,7 +127,7 @@ class ConfigureScreen(QtWidgets.QDialog):
def get_default_config(self, search_type:SearchType=None, processor_type:ProcessorType=None):
"Get default config"
config = yaml_utils.load_config_from_file(constants.app_root_directory / 'config/khoj_sample.yml')
config = constants.default_config
if search_type:
return config['content-type'][search_type]
elif processor_type: