-
Notifications
You must be signed in to change notification settings - Fork 8
Modify idx location #6
base: master
Are you sure you want to change the base?
Changes from 2 commits
bf35e5f
927d579
0ed9f66
dec7afb
72f1a65
3bf15b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,7 +252,7 @@ class DocSearch(object): | |
| LABEL_STEP_UPDATING = "label updating" | ||
| LABEL_STEP_DESTROYING = "label deletion" | ||
|
|
||
| def __init__(self, rootdir, indexdir=None, language=None, | ||
| def __init__(self, rootdir, indexdir=None, index_in_workdir=None, language=None, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add this argument at the end please ? So it doesn't break the Flatpak build if it is built before the corresponding changes in the frontend are merged. |
||
| use_default_index_client=True): | ||
| """ | ||
| Index files in rootdir (see constructor) | ||
|
|
@@ -263,17 +263,23 @@ def __init__(self, rootdir, indexdir=None, language=None, | |
| self.index = PaperworkIndexClient() | ||
|
|
||
| self.fs = fs.GioFileSystem() | ||
| self.rootdir = self.fs.safe(rootdir) | ||
|
|
||
| self.rootdir = self.fs.unsafe(rootdir) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will break if |
||
| localdir = os.path.expanduser("~/.local") | ||
| if indexdir is None: | ||
| base_data_dir = os.getenv( | ||
| "XDG_DATA_HOME", | ||
| os.path.join(localdir, "share") | ||
| ) | ||
| indexdir = os.path.join(base_data_dir, "paperwork") | ||
|
|
||
| indexdir = os.path.join(indexdir, "index") | ||
|
|
||
| if self.rootdir is not None and index_in_workdir.lower() == 'true': | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| base_data_dir = self.rootdir | ||
| localdir = base_data_dir | ||
| indexdir = os.path.join(base_data_dir, "index") | ||
|
|
||
| else: | ||
|
|
||
| if indexdir is None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
| base_data_dir = os.getenv( | ||
| "XDG_DATA_HOME", | ||
| os.path.join(localdir, "share") | ||
| ) | ||
| indexdir = os.path.join(base_data_dir, "paperwork/index") | ||
|
|
||
| label_guesser_dir = os.path.join(indexdir, "label_guessing") | ||
| self.index.open(localdir, base_data_dir, indexdir, label_guesser_dir, | ||
| rootdir, language=language) | ||
|
|
@@ -351,6 +357,7 @@ def get_doc_from_docid(self, docid, doc_type_name=None, inst=True): | |
|
|
||
| def find_documents(self, sentence, limit=None, must_sort=True, | ||
| search_type='fuzzy'): | ||
|
|
||
| return self.index.find_documents(sentence, limit=limit, | ||
| must_sort=must_sort, | ||
| search_type=search_type) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ def get_docsearch(): | |
|
|
||
| verbose("Work directory: {}".format(pconfig.settings['workdir'].value)) | ||
|
|
||
| dsearch = docsearch.DocSearch(pconfig.settings['workdir'].value) | ||
| dsearch = docsearch.DocSearch(pconfig.settings['workdir'].value, index_in_workdir = pconfig.settings['index_in_workdir'].value) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP8: No spaces around the '=' in this case. |
||
| dsearch.reload_index() | ||
| return dsearch | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make things a little bit simpler:
(see frontend:src/paperwork/frontend/util/config.py for examples)
paperwork_cfg_booleanwill take care of converting for you the read value from the configuration to a boolean.