How to use the paperwork-backend.paperwork_backend.util.mkdir_p function in paperwork-backend

To help you get started, we’ve selected a few paperwork-backend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpaperwork / paperwork / paperwork-backend / paperwork_backend / labels.py View on Github external
def load(self, label_name, force_reload=False):
        baye_dir = self._get_baye_dir(label_name)
        mkdir_p(baye_dir)
        if label_name not in self._bayes or force_reload:
            self._bayes[label_name] = simplebayes.SimpleBayes(
                cache_path=baye_dir
            )
            self._bayes[label_name].cache_train()
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / index.py View on Github external
# previous versions of whoosh don't always implement __eq__
                if str(self.index.schema) != str(self.WHOOSH_SCHEMA):
                    raise Exception("Index version mismatch")
                self.__searcher = self.index.searcher()
                need_index_rewrite = False
            except Exception as exc:
                logger.warning(
                    "Failed to open index '%s'."
                    " Will rebuild index from scratch", self.indexdir,
                    exc_info=exc
                )

            if need_index_rewrite:
                logger.info("Creating a new index")
                self.destroy_index()
                mkdir_p(self.indexdir)
                mkdir_p(self.label_guesser_dir)
                new_index = whoosh.index.create_in(
                    self.indexdir,
                    self.WHOOSH_SCHEMA
                )
                new_index.close()
                logger.info("Index '%s' created" % self.indexdir)
                if localdir in base_data_dir:
                    # windows support
                    hide_file(localdir)

        class CustomFuzzy(whoosh.qparser.query.FuzzyTerm):
            def __init__(self, fieldname, text, boost=1.0, maxdist=1,
                         prefixlength=0, constantscore=True):
                whoosh.qparser.query.FuzzyTerm.__init__(
                    self, fieldname, text, boost, maxdist,
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / index.py View on Github external
if str(self.index.schema) != str(self.WHOOSH_SCHEMA):
                    raise Exception("Index version mismatch")
                self.__searcher = self.index.searcher()
                need_index_rewrite = False
            except Exception as exc:
                logger.warning(
                    "Failed to open index '%s'."
                    " Will rebuild index from scratch", self.indexdir,
                    exc_info=exc
                )

            if need_index_rewrite:
                logger.info("Creating a new index")
                self.destroy_index()
                mkdir_p(self.indexdir)
                mkdir_p(self.label_guesser_dir)
                new_index = whoosh.index.create_in(
                    self.indexdir,
                    self.WHOOSH_SCHEMA
                )
                new_index.close()
                logger.info("Index '%s' created" % self.indexdir)
                if localdir in base_data_dir:
                    # windows support
                    hide_file(localdir)

        class CustomFuzzy(whoosh.qparser.query.FuzzyTerm):
            def __init__(self, fieldname, text, boost=1.0, maxdist=1,
                         prefixlength=0, constantscore=True):
                whoosh.qparser.query.FuzzyTerm.__init__(
                    self, fieldname, text, boost, maxdist,
                    prefixlength, constantscore=True