.
This commit is contained in:
32
config/__init__.py
Normal file
32
config/__init__.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import argparse
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
from .clockify import ClockifyConfig # noqa: F401
|
||||
from .redmine import RedmineConfig # noqa: F401
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
CLOCKIFY_TOKEN: str
|
||||
REDMINE_TOKEN: str
|
||||
CLOCKIFY_USER_ID: str
|
||||
CLOCKIFY_WORKSPACE_ID: str
|
||||
|
||||
DATETIME_FORMAT: str = "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
||||
|
||||
def configure_argument_parser():
|
||||
parser = argparse.ArgumentParser(description='Трекер трудочасов с Clockify в Redmine')
|
||||
parser.add_argument(
|
||||
'-s',
|
||||
'--start',
|
||||
help='Дата начала парсинга активностей в формате гггг-мм-дд'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-e',
|
||||
'--end',
|
||||
help='Дата окончания парсинга активностей в формате гггг-мм-дд'
|
||||
)
|
||||
return parser
|
||||
|
||||
config = Config()
|
||||
28
config/clockify.py
Normal file
28
config/clockify.py
Normal file
@@ -0,0 +1,28 @@
|
||||
class ClockifyConfig:
|
||||
def __init__(self, workspace_id: str, user_id: str):
|
||||
self.workspace_id = workspace_id
|
||||
self.user_id = user_id
|
||||
|
||||
@property
|
||||
def base_url(self):
|
||||
return "https://api.clockify.me/api/v1"
|
||||
|
||||
@property
|
||||
def tags_url(self):
|
||||
return f"/workspaces/{self.workspace_id}/tags"
|
||||
|
||||
@property
|
||||
def time_entries_url(self):
|
||||
return f"/workspaces/{self.workspace_id}/user/{self.user_id}/time-entries"
|
||||
|
||||
@property
|
||||
def user_url(self):
|
||||
return "/user"
|
||||
|
||||
@property
|
||||
def datetime_format(self):
|
||||
return "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
||||
@property
|
||||
def update_time_entry(self, activity_id):
|
||||
return f"/workspaces/{self.workspace_id}/time-entries/{activity_id}"
|
||||
16
config/redmine.py
Normal file
16
config/redmine.py
Normal file
@@ -0,0 +1,16 @@
|
||||
class RedmineConfig:
|
||||
@property
|
||||
def base_url(self):
|
||||
return "https://redmine.sbps.ru"
|
||||
|
||||
@property
|
||||
def time_entries_url(self):
|
||||
return "/time_entries.json"
|
||||
|
||||
@property
|
||||
def my_account_url(self):
|
||||
return "/my/account.json"
|
||||
|
||||
@property
|
||||
def datetime_format(self):
|
||||
return "%Y-%m-%d"
|
||||
Reference in New Issue
Block a user