Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
41490c37
Unverified
Commit
41490c37
authored
Apr 10, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add search command
parent
ed104cd0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
7 deletions
+61
-7
CHANGELOG.md
+1
-0
poetry/console/application.py
+2
-0
poetry/console/commands/__init__.py
+1
-0
poetry/console/commands/search.py
+35
-0
poetry/repositories/legacy_repository.py
+4
-0
poetry/repositories/pool.py
+9
-1
poetry/repositories/pypi_repository.py
+9
-6
No files found.
CHANGELOG.md
View file @
41490c37
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
-
Added support for Python 2.7.
-
Added support for Python 2.7.
-
Added a fallback mechanism (opt-in) for missing dependencies.
-
Added a fallback mechanism (opt-in) for missing dependencies.
-
Added
`search`
command.
### Changes
### Changes
...
...
poetry/console/application.py
View file @
41490c37
...
@@ -20,6 +20,7 @@ from .commands import PublishCommand
...
@@ -20,6 +20,7 @@ from .commands import PublishCommand
from
.commands
import
RemoveCommand
from
.commands
import
RemoveCommand
from
.commands
import
RunCommand
from
.commands
import
RunCommand
from
.commands
import
ScriptCommand
from
.commands
import
ScriptCommand
from
.commands
import
SearchCommand
from
.commands
import
ShowCommand
from
.commands
import
ShowCommand
from
.commands
import
UpdateCommand
from
.commands
import
UpdateCommand
from
.commands
import
VersionCommand
from
.commands
import
VersionCommand
...
@@ -100,6 +101,7 @@ class Application(BaseApplication):
...
@@ -100,6 +101,7 @@ class Application(BaseApplication):
RemoveCommand
(),
RemoveCommand
(),
RunCommand
(),
RunCommand
(),
ScriptCommand
(),
ScriptCommand
(),
SearchCommand
(),
ShowCommand
(),
ShowCommand
(),
UpdateCommand
(),
UpdateCommand
(),
VersionCommand
(),
VersionCommand
(),
...
...
poetry/console/commands/__init__.py
View file @
41490c37
...
@@ -10,6 +10,7 @@ from .publish import PublishCommand
...
@@ -10,6 +10,7 @@ from .publish import PublishCommand
from
.remove
import
RemoveCommand
from
.remove
import
RemoveCommand
from
.run
import
RunCommand
from
.run
import
RunCommand
from
.script
import
ScriptCommand
from
.script
import
ScriptCommand
from
.search
import
SearchCommand
from
.show
import
ShowCommand
from
.show
import
ShowCommand
from
.update
import
UpdateCommand
from
.update
import
UpdateCommand
from
.version
import
VersionCommand
from
.version
import
VersionCommand
poetry/console/commands/search.py
0 → 100644
View file @
41490c37
from
.command
import
Command
class
SearchCommand
(
Command
):
"""
Searches for packages on remote repositories.
search
{ tokens* : The tokens to search for. }
{ --N|only-name : Search only in name. }
"""
def
handle
(
self
):
from
poetry.repositories.base_repository
import
BaseRepository
flags
=
BaseRepository
.
SEARCH_FULLTEXT
if
self
.
option
(
'only-name'
):
flags
=
BaseRepository
.
SEARCH_FULLTEXT
results
=
self
.
poetry
.
pool
.
search
(
self
.
argument
(
'tokens'
),
flags
)
for
result
in
results
:
self
.
line
(
''
)
name
=
'<info>{}</>'
.
format
(
result
.
name
)
name
+=
' (<comment>{}</>)'
.
format
(
result
.
version
)
self
.
line
(
name
)
if
result
.
description
:
self
.
line
(
' {}'
.
format
(
result
.
description
)
)
poetry/repositories/legacy_repository.py
View file @
41490c37
...
@@ -52,6 +52,10 @@ class LegacyRepository(PyPiRepository):
...
@@ -52,6 +52,10 @@ class LegacyRepository(PyPiRepository):
}
}
})
})
@property
def
name
(
self
):
return
self
.
_name
def
find_packages
(
self
,
name
,
constraint
=
None
,
extras
=
None
):
def
find_packages
(
self
,
name
,
constraint
=
None
,
extras
=
None
):
packages
=
[]
packages
=
[]
...
...
poetry/repositories/pool.py
View file @
41490c37
...
@@ -4,6 +4,7 @@ from typing import Union
...
@@ -4,6 +4,7 @@ from typing import Union
import
poetry.packages
import
poetry.packages
from
.base_repository
import
BaseRepository
from
.base_repository
import
BaseRepository
from
.legacy_repository
import
LegacyRepository
from
.repository
import
Repository
from
.repository
import
Repository
...
@@ -79,4 +80,11 @@ class Pool(BaseRepository):
...
@@ -79,4 +80,11 @@ class Pool(BaseRepository):
return
[]
return
[]
def
search
(
self
,
query
,
mode
=
BaseRepository
.
SEARCH_FULLTEXT
):
def
search
(
self
,
query
,
mode
=
BaseRepository
.
SEARCH_FULLTEXT
):
raise
NotImplementedError
()
results
=
[]
for
repository
in
self
.
_repositories
:
if
isinstance
(
repository
,
LegacyRepository
):
continue
results
+=
repository
.
search
(
query
,
mode
=
mode
)
return
results
poetry/repositories/pypi_repository.py
View file @
41490c37
from
typing
import
List
from
typing
import
List
from
typing
import
Union
from
typing
import
Union
try
:
from
xmlrpc.client
import
ServerProxy
except
ImportError
:
from
xmlrpclib
import
ServerProxy
from
cachecontrol
import
CacheControl
from
cachecontrol
import
CacheControl
from
cachecontrol.caches.file_cache
import
FileCache
from
cachecontrol.caches.file_cache
import
FileCache
from
cachy
import
CacheManager
from
cachy
import
CacheManager
...
@@ -160,15 +165,13 @@ class PyPiRepository(Repository):
...
@@ -160,15 +165,13 @@ class PyPiRepository(Repository):
if
mode
==
self
.
SEARCH_FULLTEXT
:
if
mode
==
self
.
SEARCH_FULLTEXT
:
search
[
'summary'
]
=
query
search
[
'summary'
]
=
query
client
=
ServerProxy
(
self
.
_url
)
client
=
ServerProxy
(
'https://pypi.python.org/pypi'
)
hits
=
client
.
search
(
search
,
'or'
)
hits
=
client
.
search
(
search
,
'or'
)
for
hit
in
hits
:
for
hit
in
hits
:
results
.
append
({
result
=
Package
(
hit
[
'name'
],
hit
[
'version'
],
hit
[
'version'
])
'name'
:
hit
[
'name'
],
result
.
description
=
hit
[
'summary'
]
'description'
:
hit
[
'summary'
],
results
.
append
(
result
)
'version'
:
hit
[
'version'
]
})
return
results
return
results
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment