Skip to content

Commit c139d89

Browse files
committed
✨ Allow to customize language
1 parent 69ea248 commit c139d89

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/repl_python_wakatime/hooks/codestats.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
def codestats_hook(
3131
api_key: str = "",
3232
url: str = "https://codestats.net/api/my/pulses",
33-
language_type: str = "Terminal (python)",
33+
language: str = "python",
34+
language_type: str = "Terminal (%s)",
3435
service_name: str = "codestats",
3536
user_name: str = gethostname(),
3637
*args: Any,
@@ -42,12 +43,18 @@ def codestats_hook(
4243
:type api_key: str
4344
:param url:
4445
:type url: str
46+
:param language:
47+
:type language: str
4548
:param language_type:
4649
:type language_type: str
4750
:param service_name:
4851
:type service_name: str
4952
:param user_name:
5053
:type user_name: str
54+
:param args:
55+
:type args: Any
56+
:param kwargs:
57+
:type kwargs: Any
5158
:rtype: None
5259
"""
5360
global codestats
@@ -56,7 +63,7 @@ def codestats_hook(
5663
from ..utils.api import get_api_key
5764

5865
api_key = get_api_key(service_name, user_name)
59-
codestats = CodeStats(api_key, url, language_type)
66+
codestats = CodeStats(api_key, url, language_type % language)
6067
codestats.add_xp()
6168

6269

@@ -67,21 +74,24 @@ def __init__(
6774
self,
6875
api_key: str,
6976
url: str = "https://codestats.net/api/my/pulses",
70-
language_type: str = "Terminal (python)",
77+
language: str = "python",
78+
language_type: str = "Terminal (%s)",
7179
) -> None:
7280
"""Init.
7381
7482
:param api_key:
7583
:type api_key: str
7684
:param url:
7785
:type url: str
86+
:param language:
87+
:type language: str
7888
:param language_type:
7989
:type language_type: str
8090
:rtype: None
8191
"""
8292
self.url = url
8393
self.api_key = api_key
84-
self.language_type = language_type
94+
self.language_type = language_type % language
8595
self.xp_dict = {language_type: 0}
8696

8797
self.sem = threading.Semaphore()

src/repl_python_wakatime/hooks/wakatime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
def wakatime_hook(
1212
project: str = "",
13+
language: str = "python",
1314
category: str = "coding",
1415
plugin: str = "repl-python-wakatime",
1516
filenames: list[str] = [".git"],
@@ -47,8 +48,8 @@ def wakatime_hook(
4748
f"--category={category}",
4849
f"--plugin={plugin}",
4950
"--entity-type=app",
50-
"--entity=python",
51-
"--alternate-language=python",
51+
f"--entity={language}",
52+
f"--alternate-language={language}",
5253
f"--project={project}",
5354
]
5455
)

0 commit comments

Comments
 (0)