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
88afb652
Unverified
Commit
88afb652
authored
Apr 17, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the cache:clear command
parent
b8016191
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
0 deletions
+96
-0
CHANGELOG.md
+7
-0
poetry/console/application.py
+7
-0
poetry/console/commands/cache/__init__.py
+1
-0
poetry/console/commands/cache/clear.py
+81
-0
No files found.
CHANGELOG.md
View file @
88afb652
# Change Log
# Change Log
[
Unreleased
]
### Added
-
Added the
`cache:clear`
command.
## [0.8.3] - 2018-04-16
## [0.8.3] - 2018-04-16
### Fixed
### Fixed
...
...
poetry/console/application.py
View file @
88afb652
...
@@ -25,6 +25,8 @@ from .commands import ShowCommand
...
@@ -25,6 +25,8 @@ from .commands import ShowCommand
from
.commands
import
UpdateCommand
from
.commands
import
UpdateCommand
from
.commands
import
VersionCommand
from
.commands
import
VersionCommand
from
.commands.cache
import
CacheClearCommand
from
.commands.debug
import
DebugInfoCommand
from
.commands.debug
import
DebugInfoCommand
from
.commands.debug
import
DebugResolveCommand
from
.commands.debug
import
DebugResolveCommand
...
@@ -109,6 +111,11 @@ class Application(BaseApplication):
...
@@ -109,6 +111,11 @@ class Application(BaseApplication):
VersionCommand
(),
VersionCommand
(),
]
]
# Cache commands
commands
+=
[
CacheClearCommand
(),
]
# Debug commands
# Debug commands
commands
+=
[
commands
+=
[
DebugInfoCommand
(),
DebugInfoCommand
(),
...
...
poetry/console/commands/cache/__init__.py
0 → 100644
View file @
88afb652
from
.clear
import
CacheClearCommand
poetry/console/commands/cache/clear.py
0 → 100644
View file @
88afb652
import
os
import
shutil
from
..command
import
Command
class
CacheClearCommand
(
Command
):
"""
Clears poetry's cache.
cache:clear
{ cache : The name of the cache to clear. }
{ --all : Clear all caches. }
"""
def
handle
(
self
):
from
cachy
import
CacheManager
from
poetry.locations
import
CACHE_DIR
cache
=
self
.
argument
(
'cache'
)
parts
=
cache
.
split
(
':'
)
cache_dir
=
os
.
path
.
join
(
CACHE_DIR
,
'cache'
,
'repositories'
,
parts
[
0
])
cache
=
CacheManager
({
'default'
:
parts
[
0
],
'serializer'
:
'json'
,
'stores'
:
{
parts
[
0
]:
{
'driver'
:
'file'
,
'path'
:
cache_dir
}
}
})
if
len
(
parts
)
==
1
:
if
not
self
.
option
(
'all'
):
raise
RuntimeError
(
'Add the --all option if you want to clear all '
'{} caches'
.
format
(
parts
[
0
])
)
if
not
os
.
path
.
exists
(
cache_dir
):
self
.
line
(
'No cache entries for {}'
.
format
(
parts
[
0
]))
return
0
# Calculate number of entries
entries_count
=
0
for
path
,
dirs
,
files
in
os
.
walk
(
cache_dir
):
entries_count
+=
len
(
files
)
delete
=
self
.
confirm
(
'<question>Delete {} entries?</>'
.
format
(
entries_count
)
)
if
not
delete
:
return
0
cache
.
flush
()
elif
len
(
parts
)
==
2
:
raise
RuntimeError
(
'Only specifying the package name is not yet supported. '
'Add a specific version to clear'
)
elif
len
(
parts
)
==
3
:
package
=
parts
[
1
]
version
=
parts
[
2
]
if
not
cache
.
has
(
'{}:{}'
.
format
(
package
,
version
)):
self
.
line
(
'No cache entries for {}:{}'
.
format
(
package
,
version
)
)
return
0
delete
=
self
.
confirm
(
'Delete cache entry {}:{}'
.
format
(
package
,
version
)
)
if
not
delete
:
return
0
cache
.
forget
(
'{}:{}'
.
format
(
package
,
version
))
else
:
raise
ValueError
(
'Invalid cache key'
)
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