Skip to content

Commit

Permalink
Black line-length shortened.
Browse files Browse the repository at this point in the history
  • Loading branch information
coady committed Dec 18, 2019
1 parent 7f788e0 commit 97131e3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
6 changes: 4 additions & 2 deletions lupyne/engine/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ def filter(cls, *queries, **terms):
@classmethod
def disjunct(cls, multiplier, *queries, **terms):
"""Return lucene DisjunctionMaxQuery from queries and terms."""
terms = tuple(cls.term(name, value) for name, values in terms.items() for value in ([values] if isinstance(values, str) else values))
return cls(search.DisjunctionMaxQuery, Arrays.asList(queries + terms), multiplier)
queries = list(queries)
for name, values in terms.items():
queries += (cls.term(name, value) for value in ([values] if isinstance(values, str) else values))
return cls(search.DisjunctionMaxQuery, Arrays.asList(queries), multiplier)

@classmethod
def span(cls, *term):
Expand Down
12 changes: 9 additions & 3 deletions lupyne/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
* :meth:`/update <WebIndexer.update>`
Custom servers should create and mount WebSearchers and WebIndexers as needed.
:meth:`Caches <WebSearcher.update>` and :meth:`field settings <WebIndexer.fields>` can then be applied directly before `starting <#start>`_ the server.
:meth:`Caches <WebSearcher.update>` and :meth:`field settings <WebIndexer.fields>`
can then be applied directly before `starting <#start>`_ the server.
WebSearchers and WebIndexers can of course also be subclassed for custom interfaces.
CherryPy and Lucene VM integration issues:
Expand Down Expand Up @@ -244,7 +245,10 @@ def __init__(self, *directories, **kwargs):
self.urls = collections.deque(kwargs.pop('urls', ()))
if self.urls:
engine.IndexWriter(*directories).close()
self.searcher = engine.MultiSearcher(directories, **kwargs) if len(directories) > 1 else engine.IndexSearcher(*directories, **kwargs)
if len(directories) > 1:
self.searcher = engine.MultiSearcher(directories, **kwargs)
else:
self.searcher = engine.IndexSearcher(*directories, **kwargs)
self.updated = time.time()
self.query_map = {}

Expand Down Expand Up @@ -372,7 +376,9 @@ def docs(self, name=None, value='', **options):
result.update((field, dict(searcher.termvector(id, field, counts=True))) for field in options.get('fields.vector.counts', ()))
return result

docs.__annotations__.update(dict.fromkeys(['fields', 'fields.multi', 'fields.docvalues', 'fields.vector', 'fields.vector.counts'], multi))
docs.__annotations__.update(
dict.fromkeys(['fields', 'fields.multi', 'fields.docvalues', 'fields.vector', 'fields.vector.counts'], multi)
)

@cherrypy.expose
@cherrypy.tools.params()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.black]
line-length = 160
line-length = 140
skip-string-normalization = true
exclude = "docs"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
ignore = E203,F402,W605
max-line-length = 160
max-line-length = 140
exclude = docs

[tool:pytest]
Expand Down
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ def constitution():
def zipcodes():
lines = open(os.path.join(dirname, 'zipcodes.txt'))
for zipcode, latitude, longitude, state, city, county in csv.reader(lines):
yield {'zipcode': zipcode, 'latitude': float(latitude), 'longitude': float(longitude), 'city': city.title(), 'county': county.title(), 'state': state}
yield {
'zipcode': zipcode,
'latitude': float(latitude),
'longitude': float(longitude),
'city': city.title(),
'county': county.title(),
'state': state,
}
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def test_replication(tempdir, servers):
assert resource.post('update') == 1
primary.post('docs', [{}])
assert primary.post('update') == 2
time.sleep(1.1)
time.sleep(1.5)
assert sum(secondary().values()) == 2
servers.stop(servers.ports[-1])
root = server.WebSearcher(directory, urls=(primary.url, secondary.url))
Expand Down

0 comments on commit 97131e3

Please sign in to comment.