Skip to content

Commit

Permalink
✨ Allow to customize language
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 5, 2023
1 parent 69ea248 commit c139d89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/repl_python_wakatime/hooks/codestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
def codestats_hook(
api_key: str = "",
url: str = "https://codestats.net/api/my/pulses",
language_type: str = "Terminal (python)",
language: str = "python",
language_type: str = "Terminal (%s)",
service_name: str = "codestats",
user_name: str = gethostname(),
*args: Any,
Expand All @@ -42,12 +43,18 @@ def codestats_hook(
:type api_key: str
:param url:
:type url: str
:param language:
:type language: str
:param language_type:
:type language_type: str
:param service_name:
:type service_name: str
:param user_name:
:type user_name: str
:param args:
:type args: Any
:param kwargs:
:type kwargs: Any
:rtype: None
"""
global codestats
Expand All @@ -56,7 +63,7 @@ def codestats_hook(
from ..utils.api import get_api_key

api_key = get_api_key(service_name, user_name)
codestats = CodeStats(api_key, url, language_type)
codestats = CodeStats(api_key, url, language_type % language)
codestats.add_xp()


Expand All @@ -67,21 +74,24 @@ def __init__(
self,
api_key: str,
url: str = "https://codestats.net/api/my/pulses",
language_type: str = "Terminal (python)",
language: str = "python",
language_type: str = "Terminal (%s)",
) -> None:
"""Init.
:param api_key:
:type api_key: str
:param url:
:type url: str
:param language:
:type language: str
:param language_type:
:type language_type: str
:rtype: None
"""
self.url = url
self.api_key = api_key
self.language_type = language_type
self.language_type = language_type % language
self.xp_dict = {language_type: 0}

self.sem = threading.Semaphore()
Expand Down
5 changes: 3 additions & 2 deletions src/repl_python_wakatime/hooks/wakatime.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

def wakatime_hook(
project: str = "",
language: str = "python",
category: str = "coding",
plugin: str = "repl-python-wakatime",
filenames: list[str] = [".git"],
Expand Down Expand Up @@ -47,8 +48,8 @@ def wakatime_hook(
f"--category={category}",
f"--plugin={plugin}",
"--entity-type=app",
"--entity=python",
"--alternate-language=python",
f"--entity={language}",
f"--alternate-language={language}",
f"--project={project}",
]
)

0 comments on commit c139d89

Please sign in to comment.