Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint .
19 changes: 19 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[MAIN]
ignore=venv

[MESSAGES CONTROL]
disable=
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
C0301, # line-too-long
E0401, # import-error
R0903, # too-few-public-methods
R0913, # too-many-arguments
R0917, # too-many-positional-arguments
R0801, # duplicate-code
W1203, # logging-fstring-interpolation
W0511, # fixme

[REPORTS]
reports=no
3 changes: 1 addition & 2 deletions mind/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def gen_all_mindmaps(markdown_content, file_name, only_what):
md_name = output_name + ".md"
mm_name = output_name + ".mm"
svg_name = output_name

match only_what:
case 0:
generate_md(markdown_content, md_name)
Expand All @@ -27,4 +27,3 @@ def gen_all_mindmaps(markdown_content, file_name, only_what):
generate_freemind(markdown_content, mm_name)
case 3:
generate_svg(markdown_content, svg_name)

4 changes: 2 additions & 2 deletions mind/mm_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def generate_freemind(md_text, output_file="freemind-output.mm"):
for item in tree_data:
build_freemind_node(root, item)
tree = ET.ElementTree(root)

try:
with open(output_file, 'w', encoding='utf-8') as file:
with open(output_file, 'w', encoding='utf-8'):
tree.write(output_file, encoding="utf-8", xml_declaration=True)
logger.info(f"✅ The freemind mind map has been successfully generated: {output_file}")
except IOError:
Expand Down
2 changes: 1 addition & 1 deletion mind/svg_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def tree_to_svg(nodes, output_file="mindmap"):
dot.edge(node["parent"], node_id)
dot.render(output_file, view=False)

def generate_svg(md_text, output_file="mindmap"):
def generate_svg(md_text, output_file="mindmap"):
tree = parse_markdown(md_text)
# TODO try catch here
tree_to_svg(tree, output_file)
Expand Down
2 changes: 1 addition & 1 deletion pdf/pdf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def extract_and_feed_chunks(self, args, queue: asyncio.Queue):
pdf_name = str(args.pdf)
chunk_size = getattr(args, 'chunk_size', None)
overlap_size = getattr(args, 'overlap_size', None)

kwargs = {}
if chunk_size is not None:
kwargs['chunk_size'] = int(chunk_size)
Expand Down
3 changes: 2 additions & 1 deletion pdf2mind.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import asyncio
from utils.parser import cmd_parser

from pdf.pdf_reader import PdfProcess
from mind.generator import gen_all_mindmaps
from utils.parser import cmd_parser
from utils.utils import model_selector, format_selector


Expand Down
4 changes: 2 additions & 2 deletions utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def cmd_parser():
# Should not happen due to required=True
vender = "Unknown"

if not llm_key:
if not llm_key: # pylint: disable=possibly-used-before-assignment
logger.info("Error: LLM API Key is required. Please provide it via --key argument or set the XXX_API_KEY environment variable.")
sys.exit(1)

Expand All @@ -67,6 +67,6 @@ def cmd_parser():
logger.info(f"🌍 Target language: {language}")
logger.info(f"🧠 Selected vender: {vender}")
logger.info(f"🤖 Model name: {model}\n")

args = parser.parse_args()
return args
15 changes: 7 additions & 8 deletions utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

from llm.base_llm import BaseLLM
from llm.doubao_llm import DoubaoLLM
from llm.qwen_llm import QwenLLM
from llm.openai_llm import OpenaiLLM
from llm.qwen_llm import QwenLLM

def model_selector(args) -> BaseLLM:
# set default
Expand All @@ -11,19 +10,19 @@ def model_selector(args) -> BaseLLM:

if getattr(args, 'use_doubao', False):
return DoubaoLLM(args.model, args.language, max_level, temperature)
elif getattr(args, 'use_qwen', False):
if getattr(args, 'use_qwen', False):
return QwenLLM(args.model, args.language, max_level, temperature)
elif getattr(args, 'use_openai', False):
if getattr(args, 'use_openai', False):
return OpenaiLLM(args.model, args.language, max_level, temperature)
else:
raise ValueError("Please at least set one of --use-doubao、--use-qwen or --use-openai")

raise ValueError("Please at least set one of --use-doubao、--use-qwen or --use-openai")

def format_selector(args) -> int:
if args.only_freemind:
return 1
elif args.only_xmind:
if args.only_xmind:
return 2
elif args.only_svg:
if args.only_svg:
return 3
return 0

Expand Down