Skip to content

Commit

Permalink
[py] Add 'venv-list' module
Browse files Browse the repository at this point in the history
Signed-off-by: Lunik <lunik@tiwabbit.fr>
  • Loading branch information
Lunik committed Oct 26, 2023
1 parent 82f27fb commit 2f71074
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## [Unreleased]

### Features

- Add `venv-list` module to `python` collection


## v0.3.0

### Features
Expand Down
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tasks:
PACKAGE: "{{ .NAME }}"
sources:
- setup.py
- lib/**/*
generates:
- "{{ .VENV_DIR }}/*"

Expand Down
9 changes: 7 additions & 2 deletions lib/laflem/collections/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"""
from laflem.collections.base import BaseCollection

from .virtualenv import VirtualenvCleanupModule, VirtualenvCreateModule
from .virtualenv import (
VirtualenvCleanupModule,
VirtualenvCreateModule,
VirtualenvListModule,
)


class PythonCollection(BaseCollection):
Expand All @@ -14,6 +18,7 @@ class PythonCollection(BaseCollection):
name = "py"
description = "The Python collection."
modules = {
"venv-cleanup": VirtualenvCleanupModule,
"venv-create": VirtualenvCreateModule,
"venv-list": VirtualenvListModule,
"venv-cleanup": VirtualenvCleanupModule,
}
1 change: 1 addition & 0 deletions lib/laflem/collections/python/virtualenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
"""
from .cleanup import VirtualenvCleanupModule
from .create import VirtualenvCreateModule
from .list import VirtualenvListModule
31 changes: 31 additions & 0 deletions lib/laflem/collections/python/virtualenv/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Define the Virtualenv list module.
This module is used to list virtualenv in the system.
"""
import os

from laflem.log import console
from laflem.collections.base.helloworld import HelloWorldModule

from .const import VIRTUALENV_DEFAULT_FOLDER_NAME, PACKAGE_NAME


class VirtualenvListModule(HelloWorldModule):
"""
The Virtualenv list module.
"""

name = "venv-list"
description = "List Virtualenvs."
version = "0.1.0"

def _main(self, *_args, **_kwargs):
"""
Core the module.
"""

venv_path = f"{os.path.expanduser('~')}/.{PACKAGE_NAME}/python/{VIRTUALENV_DEFAULT_FOLDER_NAME}"

for venv in os.listdir(venv_path):
full_path = f"{venv_path}/{venv}"
console.print(f"- [bold blue]{venv}[/] located at [green]{full_path}[/]")

0 comments on commit 2f71074

Please sign in to comment.