Skip to content

Commit

Permalink
list branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Feb 6, 2025
1 parent c044d80 commit e81ba0a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/otoolbox/addons/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _load_repositories():

if not data:
data = env.resource_string(
RESOURCE_REPOSITORIES_PATH,
RESOURCE_REPOSITORIES_PATH,
packag_name=__name__
)
repo_list = json.loads(data)
Expand All @@ -42,7 +42,7 @@ def _load_repositories():
env.add_resource(
path="{}/{}".format(item["workspace"], item["name"]),
parent=item["workspace"],
title="Git repository: {}/{}".format(item["workspace"], item["name"]),
title=item["name"],
description="""Automaticaly added resources from git.""",
constructors=[
git.git_clone
Expand Down
4 changes: 2 additions & 2 deletions src/otoolbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class WorkspaceResourceGroup(WorkspaceResource):

def __init__(self,
path,
resources=None,
root=None,
resources=None,
root=None,
**kargs):
super().__init__(path, **kargs)
self.resources = resources if resources else []
Expand Down
20 changes: 12 additions & 8 deletions src/otoolbox/env.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
"""Envirnement fo the sysetm"""


import pkg_resources
# Standard
import os
import sys

# 3th party
import pkg_resources

# Odoo toolbox
from otoolbox.base import (
WorkspaceResource,
WorkspaceResourceGroup
)

from otoolbox.constants import(
RESOURCE_PREFIX_VIRTUAL
from otoolbox.constants import (
RESOURCE_PREFIX_VIRTUAL
)

VERSION = "0.1.0"
Expand All @@ -31,12 +34,12 @@
errors = []


def resource_string(resource_name:str, packag_name:str="otoolbox", encoding:str="utf-8"):
def resource_string(resource_name: str, packag_name: str = "otoolbox", encoding: str = "utf-8"):
"""Load resource"""
return pkg_resources.resource_string(packag_name, resource_name).decode(encoding)


def resource_stream(resource_name:str, packag_name:str="otoolbox"):
def resource_stream(resource_name: str, packag_name: str = "otoolbox"):
"""Load resource"""
return pkg_resources.resource_stream(packag_name, resource_name)

Expand All @@ -55,11 +58,12 @@ def get_workspace_path(path):
# Resource
#################################################################################
def add_resource(**kargs):
"""Add a resource to the workspace"""
resource = WorkspaceResource(**kargs)
path = kargs.get('path')
group = context['resources'].get(path)
if not group:
group = WorkspaceResourceGroup(path=path)
group = WorkspaceResourceGroup(**kargs)
group.append(resource)
context['resources'].append(group)
return sys.modules[__name__]
25 changes: 24 additions & 1 deletion src/otoolbox/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
package offers a reliable and streamlined solution for maintenance operations.
"""
import typer

from rich.console import Console
from rich.table import Table

from otoolbox import env
# from otoolbox.repositories import admin
Expand Down Expand Up @@ -46,6 +47,28 @@ def update():
return _filter_resources().update()


@app.command(name="list")
def list_repo():
"""Print list of repositories"""
table = Table(title="Repositories")
table.add_column("Parent", justify="left", style="cyan", no_wrap=True)
table.add_column("Title", justify="left", style="green", no_wrap=True)

repo_list = _filter_resources()
for repo in repo_list.resources:
table.add_row(repo.parent, repo.title)

console = Console()
console.print(table)



@app.command()
def add(organization:str, project:str, branch:str, title:str=None, description:str=None, tags:str=None):
"""Add a new repository to the workspace"""
return _filter_resources().build()


# def add_repo_list_filter(parser):
# parser.add_argument(
# '--oca',
Expand Down

0 comments on commit e81ba0a

Please sign in to comment.