Skip to content
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

Adds support to more column types #95

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
26 changes: 19 additions & 7 deletions ezissue/converter/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def format_description(string):
"""
Adds the header and a final new line to the issue description string.
"""
return str('**Issue description:**\n---\n\n' + string + '\n'*2)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it in english for now. Translations will be added later. Btw there is a branch named desenho-br I think, that writes the issue titles and stuff in pt-br and is deployed on ezissue-br lib

return str('**Descrição:**\n---\n\n' + string + '\n'*2)


def add_prefix_to_title(title, number, prefix, subid, numerate):
Expand All @@ -47,12 +47,12 @@ def add_prefix_to_title(title, number, prefix, subid, numerate):
"""
subid = subid.upper()
prefix = prefix.upper()
title = title.capitalize()
title = ' '.join([t.capitalize() for t in title.split(' ')])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this into a function plz


if numerate:
return str(prefix + subid + str(number) + " " + title)
return str(prefix + subid + str(number) + title)

return str(prefix + subid + " " + title)
return str(prefix + subid + title)


def get_all_lines(file):
Expand Down Expand Up @@ -82,11 +82,20 @@ def format_acc_criteria(string):
Formats the string adding the acceptance criteria header and adds a final
new line.
"""
checkboxes = add_md_checkbox(string)
acc_criteria_title = "**Acceptance criteria:**\n---\n\n"
checkboxes = add_md_checkbox(string) if string != 'Não há critérios.\n' else string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this logic be inside the add_md_checkbox function? It is simple, yes, but inside the function would be better organized

acc_criteria_title = "**Critérios de Aceitação:**\n---\n\n"

return "%s%s\n\n" % (acc_criteria_title, checkboxes)

return "%s%s" % (acc_criteria_title, checkboxes)
def format_extras(string):
"""
Formats the string adding the acceptance criteria header and adds a final
new line.
"""
checkboxes = add_md_checkbox(string) if string != 'Não há critérios.\n' else string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before

acc_criteria_title = "**Critérios Extras:**\n---\n\n"

return "%s%s\n\n" % (acc_criteria_title, checkboxes)

def format_tasks(string):
"""
Expand All @@ -105,6 +114,7 @@ def make_md_formatting(configuration_header, content):
"description": format_description,
"body": format_description,
"acceptance criteria": format_acc_criteria,
"extras": format_extras,
"tasks": add_md_checkbox,
}

Expand All @@ -116,6 +126,8 @@ def make_md_formatting(configuration_header, content):
if len(configuration_header) == 0 or idx == 0:
pass
else:
if (configuration_header[idx].lower() == 'acceptance criteria' or configuration_header[idx].lower() == 'extras') and content[row][idx] == '':
content[row][idx] = 'Não há critérios.\n'
print(func_dict[configuration_header[idx].lower()](
str(content[row][idx])))
content[row][idx] = \
Expand Down
19 changes: 14 additions & 5 deletions ezissue/ezissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import getpass
import requests
import json as js

import ezissue.utils as u
from ezissue.converter.manipulation import *
from ezissue.secops.secops_basic import get_token
Expand All @@ -16,15 +15,15 @@
GITLAB_BASE_URL = "https://gitlab.com/api/v4"


def create_issue_json(configuration_row, values_row, repo_host):
def create_issue_json(configuration_row, values_row, repo_host, blk):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is blk? Use significant variable names

"""
Creates a python dict with the issue's values following the format
dict({<table header>: <row value>}).
"""
n_fields = len(configuration_row)
d = dict()

blacklist = ["acceptance criteria", "tasks"]
blacklist = ["acceptance criteria", "extras", "tasks"]

if n_fields != len(values_row):
u.error(
Expand Down Expand Up @@ -54,6 +53,12 @@ def create_issue_json(configuration_row, values_row, repo_host):
d.update({'body': body})
else:
d.update({configuration_row[idx]: values_row[idx]})

for i in blk:
d[i] = eval(d[i])

print(d)

return d


Expand Down Expand Up @@ -182,11 +187,15 @@ def main(filename, repo_host, prefix, subid, numerate, debug):
row[0] = add_prefix_to_title(
row[0], idx+1, prefix, subid, numerate)

rows = make_md_formatting(columns, rows)
columns = [x.strip() for x in columns]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Significant variable names, plz

rows = [[x.strip().strip(';') for x in y] for y in rows]

blacklist = ['labels', 'assignees']
rows = make_md_formatting([x for x in columns if x not in blacklist], rows)

for row in rows:
response, issue = make_api_call(
create_issue_json(columns, row, repo_host),
create_issue_json(columns, row, repo_host, blacklist),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If blacklist is being used on various places, should be extracted to constant

url,
repo_host,
debug
Expand Down