本文整理汇总了Python中whoosh.index.exists_in函数的典型用法代码示例。如果您正苦于以下问题:Python exists_in函数的具体用法?Python exists_in怎么用?Python exists_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exists_in函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_resetsearchindexes_command_individual_index
def test_resetsearchindexes_command_individual_index(self, getdefaultlocale_mock):
self.options['indexes'] = 'user'
with self.settings(WIRECLOUD_INDEX_DIR=self.new_index_dir):
call_command('resetsearchindexes', **self.options)
self.options['stdout'].seek(0)
self.options['stderr'].seek(0)
for search_index in get_available_search_engines():
if search_index.indexname != 'user':
self.assertFalse(index.exists_in(self.new_index_dir, indexname=search_index.indexname))
self.assertTrue(index.exists_in(self.new_index_dir, indexname='user'))
开发者ID:GreenIDer-Donati,项目名称:wirecloud,代码行数:14,代码来源:commands.py
示例2: __init__
def __init__(self, indexname=IDX_NAME, index_location=None,
repo_location=None, sa=None, repo_list=None,
repo_update_list=None):
self.indexname = indexname
self.index_location = index_location
if not index_location:
raise Exception('You have to provide index location')
self.repo_location = repo_location
if not repo_location:
raise Exception('You have to provide repositories location')
self.repo_paths = ScmModel(sa).repo_scan(self.repo_location)
#filter repo list
if repo_list:
#Fix non-ascii repo names to unicode
repo_list = map(safe_unicode, repo_list)
self.filtered_repo_paths = {}
for repo_name, repo in self.repo_paths.items():
if repo_name in repo_list:
self.filtered_repo_paths[repo_name] = repo
self.repo_paths = self.filtered_repo_paths
#filter update repo list
self.filtered_repo_update_paths = {}
if repo_update_list:
self.filtered_repo_update_paths = {}
for repo_name, repo in self.repo_paths.items():
if repo_name in repo_update_list:
self.filtered_repo_update_paths[repo_name] = repo
self.repo_paths = self.filtered_repo_update_paths
self.initial = True
if not os.path.isdir(self.index_location):
os.makedirs(self.index_location)
log.info('Cannot run incremental index since it does not '
'yet exist running full build')
elif not exists_in(self.index_location, IDX_NAME):
log.info('Running full index build as the file content '
'index does not exist')
elif not exists_in(self.index_location, CHGSET_IDX_NAME):
log.info('Running full index build as the changeset '
'index does not exist')
else:
self.initial = False
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:48,代码来源:daemon.py
示例3: index_exists
def index_exists(dirname=INDEXDIR, indexname=INDEXNAME):
"""
index_exists([dirname="index", indexname="MAIN"])
Verifica se o índice :attr:`indexname` existe no diretório :attr:`dirname`.
.. code-block:: python
from storyline.engine.index import index_exists
# Exemplo em que existe o diretório index com índice MAIN.
>>> index_exists()
True
>>> index_exists("index")
True
>>> index_exists("index", "indexname")
False
:param dirname: Nome do diretório do índice.
:type dirname: str
:param indexname: Nome do índice.
:tyoe indexname: str
:returns: True ou False.
"""
return index.exists_in(dirname, indexname.upper())
开发者ID:phillipecavalcante,项目名称:storyline,代码行数:25,代码来源:index.py
示例4: get_index
def get_index(config):
"""
Return the current index object if there is one.
If not attempt to open the index in wsearch.indexdir.
If there isn't one in the dir, create one. If there is
not dir, create the dir.
"""
index_dir = config.get('wsearch.indexdir',
SEARCH_DEFAULTS['wsearch.indexdir'])
if not os.path.isabs(index_dir):
index_dir = os.path.join(config.get('root_dir', ''), index_dir)
if exists_in(index_dir):
# For now don't trap exceptions, as we don't know what they
# will be and so we want them to raise destructively.
index = open_dir(index_dir)
else:
try:
os.mkdir(index_dir)
except OSError:
pass
schema = config.get('wsearch.schema',
SEARCH_DEFAULTS['wsearch.schema'])
index = create_in(index_dir, Schema(**schema))
return index
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.whoosher,代码行数:25,代码来源:whoosher.py
示例5: createIndex
def createIndex():
if not os.path.exists(index_dir):
os.mkdir(index_dir)
if not index.exists_in(index_dir):
schema = Schema(title=TEXT(stored=True), body=TEXT(stored=True), link=TEXT(stored=True))
ix = create_in(index_dir, schema)
else:
ix = index.open_dir(index_dir)
writer = ix.writer()
for feed in source_dn_all.entries:
description = feed.summary.split("<img")
title = feed.title.encode('utf-8')
if checkIfDocExists(title, 'DN') is False:
with open('dn_news.txt', 'a') as news_file:
news_file.write(feed.title.encode('utf-8')+' \n')
writer.add_document(title=feed.title, body=description[0], link=feed['feedburner_origlink'])
for feed in source_jn_all.entries:
description = feed.summary.split("<img")
title = feed.title.encode('utf-8')
if checkIfDocExists(title, 'JN') is False:
with open('jn_news.txt', 'a') as news_file:
news_file.write(feed.title.encode('utf-8')+' \n')
writer.add_document(title=feed.title, body=description[0], link=feed['feedburner_origlink'])
writer.commit()
开发者ID:AnaSLCaldeira,项目名称:EADW,代码行数:27,代码来源:index_feed.py
示例6: get_index
def get_index(index_dir, schema=doc_schema):
lib.ensure_dir(index_dir)
if index.exists_in(index_dir):
ix = index.open_dir(index_dir)
else:
ix = index.create_in(index_dir, schema)
return ix
开发者ID:andytom,项目名称:searchr-server,代码行数:7,代码来源:document.py
示例7: run
def run(self):
# open index
self.buffer = deque(maxlen=BUFFERLINES)
if not exists(self.indexdir):
makedirs(self.indexdir)
self.ix = create_in(self.indexdir, SCHEMA)
else:
if exists_in(self.indexdir): self.ix = open_dir(self.indexdir)
else: self.ix = create_in(self.indexdir, SCHEMA)
self.qp = QueryParser("content", self.ix.schema)
self.searcher = self.ix.searcher()
index_p = self.index_p
while True:
try:
# check index_p
try:
type, data = index_p.recv()
except EOFError: break
try:
if type == QUERY: self._processSearch(data)
elif type == LOG: self._processLog(data)
elif type == RENAME: self._processRename(data)
else:
prnt("Unexpected data in logindexsearch.")
except:
print_exc()
prnt("EXCEPTION in logindexsearch process.")
except KeyboardInterrupt:
break
self._dumpBuffer(self.buffer)
self.searcher.close()
self.ix.close()
开发者ID:Clam-,项目名称:pyBurlyBot,代码行数:32,代码来源:pbm_logindexsearch.py
示例8: open_index
def open_index(self, index_folder, create_new=False):
self.index_folder = index_folder
if create_new:
if os.path.exists(index_folder):
shutil.rmtree(index_folder)
print "deleted index folder: " + index_folder
if not os.path.exists(index_folder):
os.mkdir(index_folder)
exists = index.exists_in(index_folder)
stemming_analyzer = StemmingAnalyzer()
schema = Schema(
path=ID(stored=True, unique=True)
, filename=TEXT(stored=True, field_boost=100.0)
, tags=KEYWORD(stored=True, scorable=True, field_boost=80.0)
, headlines=KEYWORD(stored=True, scorable=True, field_boost=60.0)
, doubleemphasiswords=KEYWORD(stored=True, scorable=True, field_boost=40.0)
, emphasiswords=KEYWORD(stored=True, scorable=True, field_boost=20.0)
, content=TEXT(stored=True, analyzer=stemming_analyzer)
, time=STORED
)
if not exists:
self.ix = index.create_in(index_folder, schema)
else:
self.ix = index.open_dir(index_folder)
开发者ID:BernhardWenzel,项目名称:markdown-search,代码行数:27,代码来源:search.py
示例9: _get_index
def _get_index(index_path, schema):
if index.exists_in(index_path):
return index.open_dir(index_path)
else:
if not os.path.exists(index_path):
os.mkdir(index_path)
return index.create_in(index_path, schema)
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:7,代码来源:search.py
示例10: search_files
def search_files(index_dir, content):
"""
search file content in index
if not hit: return False
if hit: return results
"""
index_exist = index.exists_in(index_dir)
if not index_exist:
print ("index not exist")
return False
ix = index.open_dir(index_dir)
content = unicode(content)
with ix.searcher() as searcher:
parser = QueryParser("content", ix.schema)
query = parser.parse(content)
# whoosh.searching.Results
results = searcher.search(query)
print (type(results))
l = len(results)
print l
for h in results:
# whoosh.searching.Hit
print type(h)
print h
return results
return False
开发者ID:justasabc,项目名称:python_tutorials,代码行数:26,代码来源:demo.py
示例11: _init_index
def _init_index(self, reset=False):
index_path = os.path.join(jupyter_data_dir(), "index")
# clear out old index if requested
if reset:
shutil.rmtree(index_path, True)
# make sure there's a path to store the index data
if not os.path.exists(index_path):
os.makedirs(index_path)
if not exists_in(index_path):
# create an index with the current schema
analyzer = ChineseAnalyzer()
schema = Schema(
basename=TEXT(stored=True, field_boost=5.0, analyzer=analyzer),
dirname=ID(stored=True, analyzer=analyzer),
path=ID(stored=True, unique=True, analyzer=analyzer),
content=TEXT(stored=False, analyzer=analyzer),
time=STORED,
)
self.ix = create_in(index_path, schema)
else:
# open the existing index
self.ix = open_dir(index_path)
# build a query parser based on the current schema
self.query_parser = MultifieldParser(["content", "basename", "dirname"], self.ix.schema)
开发者ID:huyx,项目名称:contentmanagement,代码行数:28,代码来源:index.py
示例12: __init__
def __init__(self):
self.directory = os.path.join(edocuments.root_folder, '.index')
self.dirty = False
schema = Schema(**{
PATH: ID(stored=True, unique=True),
CONTENT: TEXT(stored=True),
DATE: STORED,
DIRECTORY: STORED,
MD5: TEXT(stored=True),
})
self.parser_path = QueryParser("path_id", schema)
self.parser_content = QueryParser("content", schema)
if not exists_in(self.directory):
os.makedirs(self.directory)
self.index = create_in(self.directory, schema)
else:
self.index = open_dir(self.directory)
if 'path' in self.index.schema.names():
with self.index.writer() as writer:
writer.remove_field('path')
if 'directory' not in self.index.schema.names():
with self.index.writer() as writer:
writer.add_field('directory', STORED)
if 'md5' not in self.index.schema.names():
with self.index.writer() as writer:
writer.add_field('md5', TEXT(stored=True))
print(
'Field length:\npath: %i\ncontent: %i\nmd5: %i' % (
self.index.field_length("path_id"),
self.index.field_length("content"),
self.index.field_length("md5"),
)
)
开发者ID:sbrunner,项目名称:edocuments,代码行数:34,代码来源:index.py
示例13: search_documents
def search_documents(filter):
results = None
# Check for existing index
dir_path = os.path.join(DATA_DIR, 'index')
if not os.path.exists(dir_path) or not Index.exists_in(dir_path):
return None
index = Index.open_dir(dir_path)
if filter.startswith('tags:'):
fields = ['tags']
filter = filter[5:]
else:
fields = ['path', 'content']
parser = MultifieldParser(fields, schema=index.schema)
search_query = parser.parse(unicode(filter))
# Try documents search
try:
searcher = index.searcher(closereader=False)
return searcher.search(search_query,
collapse=[sorting.FieldFacet('path'), sorting.FieldFacet('content')],
collapse_order=sorting.FieldFacet('revision', reverse=True),
sortedby=[sorting.FieldFacet('path'), sorting.FieldFacet('date', reverse=True)]
)
finally:
searcher.close()
return results
开发者ID:vbatoufflet,项目名称:plume,代码行数:33,代码来源:search.py
示例14: __init__
def __init__(self, db_path):
ensuredir(db_path)
if index.exists_in(db_path):
self.index = index.open_dir(db_path)
else:
self.index = index.create_in(db_path, schema=self.schema)
self.qparser = QueryParser('text', self.schema)
开发者ID:lehmannro,项目名称:sphinx-mirror,代码行数:7,代码来源:whooshsearch.py
示例15: _get_index
def _get_index(self):
index_directory = "%s/%s" % (current_app.config.get("WHOOSH_BASE"), self.__class__.__name__)
if not Path(index_directory).exists():
Path(index_directory).mkdir()
model_index = None
if not index.exists_in(index_directory):
return create_in(index_directory, self._get_schema())
return index.open_dir(index_directory)
开发者ID:heyglen,项目名称:cmdb,代码行数:8,代码来源:models.py
示例16: get_or_create_index
def get_or_create_index(path, schema, src):
"""Get or create an Index."""
index = open_dir(path) if exists_in(path) else create_in(path, schema)
indexed_titles = set(field['title'] for field in gen_indexed_fields(index))
corpus = Corpus(src)
documents = set(corpus.gen_documents())
update_index(index.writer(), indexed_titles, documents)
return index
开发者ID:Ceasar,项目名称:Encyclopedia,代码行数:8,代码来源:search.py
示例17: get_location_index
def get_location_index():
if(index.exists_in(whoosh_index_path, indexname="location_index")):
loc_ix = index.open_dir(whoosh_index_path, indexname="location_index")
else:
loc_ix = index.create_in(whoosh_index_path, schema=LocationSchema(),
indexname="location_index")
fill_location_index(loc_ix)
return loc_ix
开发者ID:ZachSand,项目名称:cs373-idb,代码行数:8,代码来源:whoosh_index.py
示例18: get_category_index
def get_category_index():
if(index.exists_in(whoosh_index_path, indexname="category_index")):
cat_ix = index.open_dir(whoosh_index_path, indexname="category_index")
else:
cat_ix = index.create_in(whoosh_index_path, schema=CategorySchema(),
indexname="category_index")
fill_category_index(cat_ix)
return cat_ix
开发者ID:ZachSand,项目名称:cs373-idb,代码行数:8,代码来源:whoosh_index.py
示例19: get_restaurant_index
def get_restaurant_index():
if(index.exists_in(whoosh_index_path, indexname="restaurant_index")):
rest_ix = index.open_dir(whoosh_index_path, indexname="restaurant_index")
else:
rest_ix = index.create_in(whoosh_index_path, schema=RestaurantSchema(),
indexname="restaurant_index")
fill_restaurant_index(rest_ix)
return rest_ix
开发者ID:ZachSand,项目名称:cs373-idb,代码行数:8,代码来源:whoosh_index.py
示例20: get_index
def get_index(self):
ip = self.indexpath
if not self.indexpath.startswith('/'):
ip = path.join(self.env.path, ip)
if not path.exists(ip):
os.mkdir(ip)
if not index.exists_in(ip):
index.create_in(ip, self.SCHEMA)
return index.open_dir(ip)
开发者ID:dokipen,项目名称:trac-irclogs-plugin,代码行数:9,代码来源:search.py
注:本文中的whoosh.index.exists_in函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论