Skip to content

feat: add case converter for matching keyword #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Feb 4, 2023
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PyGithub = "==1.57"
setuptools = "*"
wheel = "*"
semgrep = "*"
inflection = "*"

[requires]
python_version = "3.9"
23 changes: 16 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Set,
)

from inflection import humanize

from services import fetch_pull_request

TAG = [
Expand Down Expand Up @@ -54,33 +56,32 @@ def __parse_title(title: str):
def __highlight(text: str, keywords: Set[str]):
highlighted = text
for k in keywords:
if len(k) < 2 or k.find(','):
try:
highlighted = highlighted.replace(k, f'`{k}`')
except ValueError:
continue
highlighted = highlighted.replace(k, f'`{k}`')
return highlighted


def main():
owner = env['owner']
repo = env['repository']
pull_request_num = int(env['pull_request_number'])
token = env['access_token']
src_path = env['src_path']
symbols = env["symbols"]
keywords = set(symbols.split('\n'))
symbol_list = [humanize(symbol).lower().strip()
for symbol in symbols.split('\n') if len(humanize(symbol).lower().strip()) > 3]
symbol_list.extend([symbol.replace(' ', '_') for symbol in symbol_list])
keywords = set(symbol_list)

pull_request = fetch_pull_request(
access_token=token,
owner=owner,
repository=repo,
number=pull_request_num,
access_token=env['access_token'],
owner=env['owner'],
repository=env['repository'],
number=int(env['pull_request_number']),
)

if not __can_process(pull_request.title):
return

files = []
for root, _, f_names in os.walk(src_path):
for root, _, f_names in os.walk(env['src_path']):
for f in f_names:
file_path = os.path.join(root, f)
if file_path.startswith('./.venv'):
Expand Down