Compare commits

..

1 Commits

Author SHA1 Message Date
f0a7fd9ed6 modul example 2024-11-22 12:23:37 +01:00
6 changed files with 29 additions and 66 deletions

View File

@ -1,6 +1,2 @@
# sccpy
zur installation
```bash
pip install git+https://git.seemsleg.it/pub/sccpy.git
```

View File

@ -1,3 +1 @@
requests
pydantic

View File

@ -1,4 +1,4 @@
from .core import getOrg, getOrgMembers, getUser
#from .modules import *
from .modules import *
__all__ = ["getOrg", "getOrgMembers", "getUser"]

View File

@ -1,24 +1,4 @@
from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import date
class User(BaseModel):
handle: str
name: str
enlisted: date # Datum
citizenrecord: Optional[int] # Integer oder None
languages: List[str] = Field(default_factory=list) # Liste von Strings
class OrgMember(User):
rang: str
star: int
affiliate: bool
class Org(BaseModel):
sid: str
name: str
membercount: int
fokus: List[str] = Field(default_factory=list)
# core.py
def getOrg(org_id):
"""
@ -26,12 +6,7 @@ def getOrg(org_id):
:param org_id: The ID of the organization.
:return: A dictionary with organization details.
"""
return Org(
sid=f"org_{org_id}",
name=f"Organization {org_id}",
membercount=42, # Beispielwert
fokus=["Innovation", "Technology"] # Beispiel für Schwerpunkte
)
return {"id": org_id, "name": f"Org-{org_id}"}
def getOrgMembers(org_id):
"""
@ -39,30 +14,7 @@ def getOrgMembers(org_id):
:param org_id: The ID of the organization.
:return: A list of dictionaries representing members.
"""
return [
OrgMember(
handle=f"user_{org_id}_1",
name="John Doe",
mainorg=f"org_{org_id}",
enlisted=date(2020, 5, 1),
citizenrecord=101,
languages=["English", "Spanish"],
rang="Senior",
star=5,
affiliate=True
),
OrgMember(
handle=f"user_{org_id}_2",
name="Jane Smith",
mainorg=f"org_{org_id}",
enlisted=date(2021, 7, 15),
citizenrecord=None,
languages=["German"],
rang="Junior",
star=2,
affiliate=False
),
]
return [{"id": i, "name": f"Member-{i}"} for i in range(1, 6)]
def getUser(user_id):
"""
@ -70,11 +22,4 @@ def getUser(user_id):
:param user_id: The ID of the user.
:return: A dictionary with user details.
"""
return User(
handle=f"user_{user_id}",
name=f"User {user_id}",
mainorg="ExampleCorp",
enlisted=date(2023, 1, 15), # Beispiel für ein Datum
citizenrecord=user_id if user_id % 2 == 0 else None, # Integer oder None
languages=["English", "German"]
)
return {"id": user_id, "name": f"User-{user_id}"}

16
sccpy/modules/__init__.py Normal file
View File

@ -0,0 +1,16 @@
# modules/__init__.py
# Importiere Untermodule dynamisch
import os
import importlib
# Automatisch alle Python-Dateien im modules-Ordner als Untermodule laden
__all__ = []
modules_dir = os.path.dirname(__file__)
for filename in os.listdir(modules_dir):
if filename.endswith(".py") and filename != "__init__.py":
module_name = filename[:-3]
module = importlib.import_module(f"sccpy.modules.{module_name}")
globals()[module_name] = module
__all__.append(module_name)

8
sccpy/modules/example.py Normal file
View File

@ -0,0 +1,8 @@
# example.py
def exampleFunction():
"""
Example function in a module.
:return: A string message.
"""
return "This is an example function from a module."