MakiAi commited on
Commit
b8c0cd8
·
1 Parent(s): c60182b

🆕 [feat] harmon_aiパッケージの初期設定

Browse files

- harmon_aiクラスをimportするための__init__.pyファイルを作成

.Prothiel.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HarmonAI
2
+
3
+ ## Description
4
+ HarmonAIは、リポジトリの名前、Githubのオーナー名、パッケージ名から、PyPIとGithubのshields.ioバッジのHTMLコードを生成し、READMEファイルのテンプレートを出力するためのPythonライブラリです。このライブラリは、パッケージとしてインポートして使用することも、コマンドラインインターフェース(CLI)から直接使用することもできます。
5
+
6
+ ## File Structure
7
+ ```
8
+ - harmon_ai/
9
+ - __init__.py
10
+ - harmon_ai.py
11
+ - cli.py
12
+ - templates/
13
+ - __init__.py
14
+ - badges_template.html
15
+ - readme_template.md
16
+ - tests/
17
+ - __init__.py
18
+ - test_harmon_ai.py
19
+ - setup.py
20
+ - README.md
21
+ - requirements.txt
22
+ ```
23
+
24
+ ## Source Code
25
+ ### harmon_ai/__init__.py
26
+ ```python
27
+ from .harmon_ai import HarmonAI
28
+ ```
29
+
30
+ ### harmon_ai/harmon_ai.py
31
+ ```python
32
+ import os
33
+
34
+ class HarmonAI:
35
+ @staticmethod
36
+ def generate_readme(repo_name, owner_name, package_name, icon_url, title, subtitle, important_message, sections_content):
37
+ with open(os.path.join(os.path.dirname(__file__), "templates", "readme_template.md"), "r") as file:
38
+ template = file.read()
39
+
40
+ badge_template = HarmonAI.generate_badges(repo_name, owner_name, package_name)
41
+
42
+ template = template.replace("{repo_name}", repo_name)
43
+ template = template.replace("{owner_name}", owner_name)
44
+ template = template.replace("{package_name}", package_name)
45
+ template = template.replace("{icon_url}", icon_url)
46
+ template = template.replace("{title}", title)
47
+ template = template.replace("{subtitle}", subtitle)
48
+ template = template.replace("{badges}", badge_template)
49
+ template = template.replace("{important_message}", important_message)
50
+ template = template.replace("{sections_content}", sections_content)
51
+
52
+ return template
53
+
54
+ @staticmethod
55
+ def generate_badges(repo_name, owner_name, package_name):
56
+ with open(os.path.join(os.path.dirname(__file__), "templates", "badges_template.html"), "r") as file:
57
+ template = file.read()
58
+
59
+ template = template.replace("{repo_name}", repo_name)
60
+ template = template.replace("{owner_name}", owner_name)
61
+ template = template.replace("{package_name}", package_name)
62
+
63
+ return template
64
+ ```
65
+
66
+ ### harmon_ai/cli.py
67
+ ```python
68
+ import argparse
69
+ from .harmon_ai import HarmonAI
70
+
71
+ def main():
72
+ parser = argparse.ArgumentParser(description="Generate README template and badges for a GitHub repository.")
73
+ parser.add_argument("repo_name", help="Name of the GitHub repository")
74
+ parser.add_argument("owner_name", help="GitHub username of the repository owner")
75
+ parser.add_argument("package_name", help="Name of the package")
76
+ parser.add_argument("icon_url", help="URL of the icon to display in the README")
77
+ parser.add_argument("title", help="Title of the project")
78
+ parser.add_argument("subtitle", help="Subtitle of the project")
79
+ parser.add_argument("important_message", help="Important message to display in the README")
80
+ parser.add_argument("sections_content", help="Content of the README sections (introduction, demo, getting_started, updates, contributing, license, acknowledgements) in markdown format")
81
+
82
+ args = parser.parse_args()
83
+
84
+ readme_template = HarmonAI.generate_readme(
85
+ args.repo_name,
86
+ args.owner_name,
87
+ args.package_name,
88
+ args.icon_url,
89
+ args.title,
90
+ args.subtitle,
91
+ args.important_message,
92
+ args.sections_content
93
+ )
94
+
95
+ print(readme_template)
96
+
97
+ if __name__ == "__main__":
98
+ main()
99
+ ```
100
+
101
+ ### harmon_ai/templates/__init__.py
102
+ ```python
103
+ # Empty file
104
+ ```
105
+
106
+ ### harmon_ai/templates/badges_template.html
107
+ ```html
108
+ <img alt="PyPI - Version" src="https://img.shields.io/pypi/v/{package_name}">
109
+ <img alt="PyPI - Format" src="https://img.shields.io/pypi/format/{package_name}">
110
+ <img alt="PyPI - Implementation" src="https://img.shields.io/pypi/implementation/{package_name}">
111
+ <img alt="PyPI - Status" src="https://img.shields.io/pypi/status/{package_name}">
112
+ <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dd/{package_name}">
113
+ <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dw/{package_name}">
114
+ <a href="https://github.com/{owner_name}/{repo_name}" title="Go to GitHub repo"><img src="https://img.shields.io/static/v1?label={repo_name}&message={owner_name}&color=blue&logo=github"></a>
115
+ <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/{owner_name}/{repo_name}">
116
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="forks - {owner_name}" src="https://img.shields.io/github/forks/{repo_name}/{owner_name}?style=social"></a>
117
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="GitHub Last Commit" src="https://img.shields.io/github/last-commit/{owner_name}/{repo_name}"></a>
118
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="GitHub Top Language" src="https://img.shields.io/github/languages/top/{owner_name}/{repo_name}"></a>
119
+ <img alt="GitHub Release" src="https://img.shields.io/github/v/release/{owner_name}/{repo_name}?color=red">
120
+ <img alt="GitHub Tag" src="https://img.shields.io/github/v/tag/{owner_name}/{repo_name}?sort=semver&color=orange">
121
+ <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/{owner_name}/{repo_name}/publish-to-pypi.yml">
122
+ ```
123
+
124
+ ### harmon_ai/templates/readme_template.md
125
+ ```markdown
126
+ <p align="center">
127
+ <img src="{icon_url}" width="100%">
128
+ <br>
129
+ <h1 align="center">{title}</h1>
130
+ <h2 align="center">
131
+ {subtitle}
132
+
133
+ {badges}
134
+
135
+ </h2>
136
+
137
+ </p>
138
+
139
+ >[!IMPORTANT]
140
+ >{important_message}
141
+
142
+ {sections_content}
143
+ ```
144
+
145
+ ### tests/__init__.py
146
+ ```python
147
+ # Empty file
148
+ ```
149
+
150
+ ### tests/test_harmon_ai.py
151
+ ```python
152
+ import unittest
153
+ from harmon_ai import HarmonAI
154
+
155
+ class TestHarmonAI(unittest.TestCase):
156
+ def test_generate_badges(self):
157
+ repo_name = "test-repo"
158
+ owner_name = "test-owner"
159
+ package_name = "test-package"
160
+
161
+ with open("harmon_ai/templates/badges_template.html", "r") as file:
162
+ expected_output = file.read()
163
+
164
+ expected_output = expected_output.replace("{repo_name}", repo_name)
165
+ expected_output = expected_output.replace("{owner_name}", owner_name)
166
+ expected_output = expected_output.replace("{package_name}", package_name)
167
+
168
+ result = HarmonAI.generate_badges(repo_name, owner_name, package_name)
169
+ self.assertEqual(result, expected_output)
170
+
171
+ def test_generate_readme(self):
172
+ repo_name = "test-repo"
173
+ owner_name = "test-owner"
174
+ package_name = "test-package"
175
+ icon_url = "https://example.com/icon.png"
176
+ title = "Test Title"
177
+ subtitle = "Test Subtitle"
178
+ important_message = "This is an important message."
179
+
180
+ sections_content = '''
181
+ ## Introduction
182
+ This is the introduction.
183
+
184
+ ## Demo
185
+ This is the demo.
186
+
187
+ ## Getting Started
188
+ This is how to get started.
189
+
190
+ ## Updates
191
+ These are the updates.
192
+
193
+ ## Contributing
194
+ This is how to contribute.
195
+
196
+ ## License
197
+ This is the license.
198
+
199
+ ## Acknowledgements
200
+ These are the acknowledgements.
201
+ '''
202
+
203
+ with open("harmon_ai/templates/readme_template.md", "r") as file:
204
+ expected_output = file.read()
205
+
206
+ expected_output = expected_output.replace("{repo_name}", repo_name)
207
+ expected_output = expected_output.replace("{owner_name}", owner_name)
208
+ expected_output = expected_output.replace("{package_name}", package_name)
209
+ expected_output = expected_output.replace("{icon_url}", icon_url)
210
+ expected_output = expected_output.replace("{title}", title)
211
+ expected_output = expected_output.replace("{subtitle}", subtitle)
212
+ expected_output = expected_output.replace("{badges}", HarmonAI.generate_badges(repo_name, owner_name, package_name))
213
+ expected_output = expected_output.replace("{important_message}", important_message)
214
+ expected_output = expected_output.replace("{sections_content}", sections_content)
215
+
216
+ result = HarmonAI.generate_readme(repo_name, owner_name, package_name, icon_url, title, subtitle, important_message, sections_content)
217
+ self.assertEqual(result, expected_output)
218
+
219
+ if __name__ == "__main__":
220
+ unittest.main()
221
+ ```
222
+
223
+ ### setup.py
224
+ ```python
225
+ from setuptools import setup, find_packages
226
+
227
+ setup(
228
+ name="harmon_ai",
229
+ version="0.1.0",
230
+ packages=find_packages(),
231
+ include_package_data=True,
232
+ install_requires=[
233
+ # Add any dependencies here
234
+ ],
235
+ entry_points={
236
+ "console_scripts": [
237
+ "harmon-ai = harmon_ai.cli:main"
238
+ ]
239
+ },
240
+ classifiers=[
241
+ "Development Status :: 3 - Alpha",
242
+ "Intended Audience :: Developers",
243
+ "License :: OSI Approved :: MIT License",
244
+ "Programming Language :: Python :: 3",
245
+ "Programming Language :: Python :: 3.6",
246
+ "Programming Language :: Python :: 3.7",
247
+ "Programming Language :: Python :: 3.8",
248
+ "Programming Language :: Python :: 3.9",
249
+ ],
250
+ )
251
+ ```
.github/workflows/publish-to-pypi.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish Python Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment:
11
+ name: pypi
12
+ url: https://pypi.org/p/harmon_ai
13
+ permissions:
14
+ id-token: write
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v4
19
+ with:
20
+ python-version: '3.x'
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install build
25
+ - name: Build package
26
+ run: python -m build
27
+ - name: Publish package
28
+ uses: pypa/gh-action-pypi-publish@release/v1
29
+ with:
30
+ skip-existing: true
.gitignore CHANGED
@@ -160,4 +160,6 @@ cython_debug/
160
  #.idea/
161
 
162
  SourceSageAssets
163
- tmp2.md
 
 
 
160
  #.idea/
161
 
162
  SourceSageAssets
163
+ tmp2.md
164
+ .harmon_ai
165
+ .Gaiah.md
app.py CHANGED
@@ -1,15 +1,18 @@
1
  import streamlit as st
 
 
 
 
2
 
3
-
4
- # def load_markdown(file_path):
5
- # with open(file_path, encoding="utf8") as f:
6
- # return f.read()
7
-
8
- # def display_front_page():
9
- # html_front = load_markdown('docs/page_front.md')
10
- # st.markdown(f"{html_front}", unsafe_allow_html=True)
11
 
 
 
 
 
 
 
12
  if __name__ == "__main__":
13
- # display_front_page()
14
- x = st.slider('Select a value')
15
- st.write(x, 'squared is', x * x)
 
1
  import streamlit as st
2
+ from harmon_ai import HarmonAI
3
+ # from templates.header import show_header
4
+ # from templates.sidebar import show_sidebar
5
+ # from templates.footer import show_footer
6
 
7
+ def main():
8
+ # show_header()
9
+ # repo_name, owner_name, package_name, icon_url, title, subtitle, important_message = show_sidebar()
 
 
 
 
 
10
 
11
+ if st.button("Generate README"):
12
+ pass
13
+ # readme_text = HarmonAI.generate_readme(repo_name, owner_name, package_name, icon_url, title, subtitle, important_message)
14
+ # st.markdown(readme_text)
15
+ # show_footer()
16
+
17
  if __name__ == "__main__":
18
+ main()
 
 
harmon_ai/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .harmon_ai import harmon_ai
harmon_ai/cli.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ from .harmon_ai import harmon_ai
4
+
5
+ def main():
6
+ parser = argparse.ArgumentParser(description="GitHubリポジトリ用のREADMEテンプレートとバッジを生成します。")
7
+ parser.add_argument("--repo_name", help="GitHubリポジトリの名前", default="your-repo")
8
+ parser.add_argument("--owner_name", help="リポジトリオーナーのGitHubユーザー名", default="your-github-username")
9
+ parser.add_argument("--package_name", help="パッケージの名前", default="your-package")
10
+ parser.add_argument("--icon_url", help="READMEに表示するアイコンのURL", default="https://example.com/icon.png")
11
+ parser.add_argument("--title", help="プロジェクトのタイトル", default="Your Project Title")
12
+ parser.add_argument("--subtitle", help="プロジェクトのサブタイトル", default="Your Project Subtitle")
13
+ parser.add_argument("--important_message", help="READMEに表示する重要なメッセージ", default=None)
14
+ parser.add_argument("--sections_content", help="READMEのセクションの内容(introduction, demo, getting_started, updates, contributing, license, acknowledgements)をマークダウン形式で指定", default=None)
15
+ parser.add_argument("--output_dir", help="生成されたREADMEファイルの出力ディレクトリ", default=".harmon_ai")
16
+ parser.add_argument("--output_file", help="生成されたREADMEファイルの名前", default="_README_template.md")
17
+
18
+ args = parser.parse_args()
19
+
20
+ if args.important_message is None:
21
+ with open(os.path.join(os.path.dirname(__file__), "templates", "important_template.md"), "r", encoding="utf8") as file:
22
+ args.important_message = file.read()
23
+
24
+ if args.sections_content is None:
25
+ with open(os.path.join(os.path.dirname(__file__), "templates", "sections_template.md"), "r", encoding="utf8") as file:
26
+ args.sections_content = file.read()
27
+
28
+ readme_template = harmon_ai.generate_readme(
29
+ args.repo_name,
30
+ args.owner_name,
31
+ args.package_name,
32
+ args.icon_url,
33
+ args.title,
34
+ args.subtitle,
35
+ args.important_message,
36
+ args.sections_content
37
+ )
38
+
39
+ os.makedirs(args.output_dir, exist_ok=True)
40
+ output_path = os.path.join(args.output_dir, args.output_file)
41
+ with open(output_path, "w", encoding="utf8") as file:
42
+ file.write(readme_template)
43
+
44
+ print(f"READMEファイルが生成されました: {output_path}")
45
+
46
+ if __name__ == "__main__":
47
+ main()
harmon_ai/harmon_ai.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ class harmon_ai:
4
+ @staticmethod
5
+ def generate_readme(repo_name, owner_name, package_name, icon_url, title, subtitle, important_message, sections_content):
6
+ with open(os.path.join(os.path.dirname(__file__), "templates", "readme_template.md"), "r") as file:
7
+ template = file.read()
8
+
9
+ badge_template = harmon_ai.generate_badges(repo_name, owner_name, package_name)
10
+
11
+ template = template.replace("{repo_name}", repo_name)
12
+ template = template.replace("{owner_name}", owner_name)
13
+ template = template.replace("{package_name}", package_name)
14
+ template = template.replace("{icon_url}", icon_url)
15
+ template = template.replace("{title}", title)
16
+ template = template.replace("{subtitle}", subtitle)
17
+ template = template.replace("{badges}", badge_template)
18
+ template = template.replace("{important_message}", important_message)
19
+ template = template.replace("{sections_content}", sections_content)
20
+
21
+ return template
22
+
23
+ @staticmethod
24
+ def generate_badges(repo_name, owner_name, package_name):
25
+ with open(os.path.join(os.path.dirname(__file__), "templates", "badges_template.md"), "r") as file:
26
+ template = file.read()
27
+
28
+ template = template.replace("{repo_name}", repo_name)
29
+ template = template.replace("{owner_name}", owner_name)
30
+ template = template.replace("{package_name}", package_name)
31
+
32
+ return template
harmon_ai/templates/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Empty file
harmon_ai/templates/badges_template.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <img alt="PyPI - Version" src="https://img.shields.io/pypi/v/{package_name}">
2
+ <img alt="PyPI - Format" src="https://img.shields.io/pypi/format/{package_name}">
3
+ <img alt="PyPI - Implementation" src="https://img.shields.io/pypi/implementation/{package_name}">
4
+ <img alt="PyPI - Status" src="https://img.shields.io/pypi/status/{package_name}">
5
+ <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dd/{package_name}">
6
+ <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dw/{package_name}">
7
+ <a href="https://github.com/{owner_name}/{repo_name}" title="Go to GitHub repo"><img src="https://img.shields.io/static/v1?label={repo_name}&message={owner_name}&color=blue&logo=github"></a>
8
+ <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/{owner_name}/{repo_name}">
9
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="forks - {owner_name}" src="https://img.shields.io/github/forks/{repo_name}/{owner_name}?style=social"></a>
10
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="GitHub Last Commit" src="https://img.shields.io/github/last-commit/{owner_name}/{repo_name}"></a>
11
+ <a href="https://github.com/{owner_name}/{repo_name}"><img alt="GitHub Top Language" src="https://img.shields.io/github/languages/top/{owner_name}/{repo_name}"></a>
12
+ <img alt="GitHub Release" src="https://img.shields.io/github/v/release/{owner_name}/{repo_name}?color=red">
13
+ <img alt="GitHub Tag" src="https://img.shields.io/github/v/tag/{owner_name}/{repo_name}?sort=semver&color=orange">
14
+ <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/{owner_name}/{repo_name}/publish-to-pypi.yml">
harmon_ai/templates/important_template.md ADDED
@@ -0,0 +1 @@
 
 
1
+ このリポジトリは[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage)を活用しており、リリースノートやREADME、コミットメッセージの9割は[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage) + [claude.ai](https://claude.ai/)で生成しています。
harmon_ai/templates/readme_template.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="{icon_url}" width="100%">
3
+ <br>
4
+ <h1 align="center">{title}</h1>
5
+ <h2 align="center">
6
+ {subtitle}
7
+ <br>
8
+ {badges}
9
+
10
+ </h2>
11
+
12
+ </p>
13
+
14
+ >[!IMPORTANT]
15
+ >{important_message}
16
+
17
+ {sections_content}
harmon_ai/templates/sections_template.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 🌟 Introduction
2
+
3
+ ## 🎥 Demo
4
+
5
+ ## 🚀 Getting Started
6
+
7
+ ## 📝 Updates
8
+
9
+ ## 🤝 Contributing
10
+
11
+ ## 📄 License
12
+
13
+ ## 🙏 Acknowledgements
script/activate-harmon_ai_dev.bat ADDED
@@ -0,0 +1 @@
 
 
1
+ conda activate harmon_ai_dev
setup.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="harmon_ai",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ include_package_data=True,
8
+ install_requires=[
9
+ # Add any dependencies here
10
+ ],
11
+ entry_points={
12
+ "console_scripts": [
13
+ "harmon-ai = harmon_ai.cli:main"
14
+ ]
15
+ },
16
+ classifiers=[
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.6",
22
+ "Programming Language :: Python :: 3.7",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ ],
26
+ )
tests/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Empty file
tests/test_harmon_ai.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+ from harmon_ai import harmon_ai
3
+
4
+ class Testharmon_ai(unittest.TestCase):
5
+ def test_generate_badges(self):
6
+ repo_name = "test-repo"
7
+ owner_name = "test-owner"
8
+ package_name = "test-package"
9
+
10
+ with open("harmon_ai/templates/badges_template.html", "r") as file:
11
+ expected_output = file.read()
12
+
13
+ expected_output = expected_output.replace("{repo_name}", repo_name)
14
+ expected_output = expected_output.replace("{owner_name}", owner_name)
15
+ expected_output = expected_output.replace("{package_name}", package_name)
16
+
17
+ result = harmon_ai.generate_badges(repo_name, owner_name, package_name)
18
+ self.assertEqual(result, expected_output)
19
+
20
+ def test_generate_readme(self):
21
+ repo_name = "test-repo"
22
+ owner_name = "test-owner"
23
+ package_name = "test-package"
24
+ icon_url = "https://example.com/icon.png"
25
+ title = "Test Title"
26
+ subtitle = "Test Subtitle"
27
+ important_message = "This is an important message."
28
+
29
+ sections_content = '''
30
+ ## Introduction
31
+ This is the introduction.
32
+
33
+ ## Demo
34
+ This is the demo.
35
+
36
+ ## Getting Started
37
+ This is how to get started.
38
+
39
+ ## Updates
40
+ These are the updates.
41
+
42
+ ## Contributing
43
+ This is how to contribute.
44
+
45
+ ## License
46
+ This is the license.
47
+
48
+ ## Acknowledgements
49
+ These are the acknowledgements.
50
+ '''
51
+
52
+ with open("harmon_ai/templates/readme_template.md", "r") as file:
53
+ expected_output = file.read()
54
+
55
+ expected_output = expected_output.replace("{repo_name}", repo_name)
56
+ expected_output = expected_output.replace("{owner_name}", owner_name)
57
+ expected_output = expected_output.replace("{package_name}", package_name)
58
+ expected_output = expected_output.replace("{icon_url}", icon_url)
59
+ expected_output = expected_output.replace("{title}", title)
60
+ expected_output = expected_output.replace("{subtitle}", subtitle)
61
+ expected_output = expected_output.replace("{badges}", harmon_ai.generate_badges(repo_name, owner_name, package_name))
62
+ expected_output = expected_output.replace("{important_message}", important_message)
63
+ expected_output = expected_output.replace("{sections_content}", sections_content)
64
+
65
+ result = harmon_ai.generate_readme(repo_name, owner_name, package_name, icon_url, title, subtitle, important_message, sections_content)
66
+ self.assertEqual(result, expected_output)
67
+
68
+ if __name__ == "__main__":
69
+ unittest.main()