def landing_page(): token = get_jira_token() e = easydict() e._user_select_options = get_user_select_options_html(token) e._none_selected = "selected" if not token else "" s = easydict() s._user_select = templates.user_select.format(**e) s._homerow = get_homerow_html(token) return templates.landing_html.format(**s)
def parse_config_file(path_to_config): with open(path_to_config) as f: cfg = yaml.load(f) return easydict(cfg)
def get_resp_data(resp): data = resp.read() if resp.headers.get('Content-Encoding') == 'gzip': data = gunzip(data) if resp.headers.gettype() == 'application/json': data = easydict(json.loads(data)) if data else None return data
def parse_uri(uri): if uri is None: return None, None if '?' in uri: path, qs = uri.split('?', 1) qpd = parse_qs(qs) return path, easydict(qpd) else: return uri, None
def get_post_response_html__old(issue, resp): if resp_ok(resp): url = resp.geturl() resp_data = get_resp_data(resp) e = easydict() e._url = escape_html(url, quot=True) e._headers = escape_html(str(resp.headers)) e._body = json.dumps(resp_data, sort_keys=1, indent=2) e._code = resp.getcode() e._msg = resp.msg e.key = issue return templates.post_response_html.format(**e)
def get_render_page_html(jml): e = easydict() if jml: issue = 'SOFTWARE-1234' # arbitrarily resp = render_jira_markup(issue, jml) e._rendered = get_resp_data(resp) e._jml = escape_html(jml) else: e._rendered = '' e._jml = '' return _render_test_html.format(**e)
def get_error_page_html(resp): if not resp: return templates.cookies_required_html url = resp.geturl() body = get_resp_data(resp) e = easydict() e._url = escape_html(url, quot=True) e._headers = escape_html(str(resp.headers)) e._body = json.dumps(body, sort_keys=1, indent=2) e._code = resp.getcode() e._msg = resp.msg e._emsgs = "\n".join(body.errorMessages or []) return templates.error_page_html.format(**e)
def get_user_issues_html(user): resp = get_user_issues(user) e = get_resp_data(resp) users = get_user_lookup_d() token = get_jira_token() f = easydict() f._user = users.get(user, user) f._homerow = get_homerow_html(token) html = templates.user_issue_html_links1.format(**f) for isu in sorted(e.issues, reverse=True, key=user_issue_sortkey): html += add_user_issue_fields(isu) html += templates.user_issue_html_links3 return html
def get_add_comment_html(params): e = easydict() e.key = params.comment e._summary = params.summary if params.jml and params.action == 'Add': return get_add_comment_response_html(e.key, params.jml) e._user_lookup = get_user_lookup_options_html() if params.jml: resp = render_jira_markup(e.key, params.jml) e._rendered = get_resp_data(resp) e._rbox = 'rbox' e._jml = escape_html(params.jml) else: e._rendered = '' e._rbox = '' e._jml = '' token = get_jira_token() e._homerow = get_homerow_html(token) return templates.add_comment_html.format(**e)
def login_page(params): if params.token: return login_page_redir(params) e = easydict() token = '' expiry_date = '' c = get_token_cookie() if c: token = c.value if c.expires: expiry_date = "(%s)" % format_date(c.expires) e._token = escape_html(token) if token else '' e._expiry_date = expiry_date e._homerow = get_homerow_html(token) e._jira = jira_url if params.login == 'help': e._extrahelp = templates.login_extrahelp.format(**e) else: e._extrahelp = '' html = templates.login_page.format(**e) return html
from easydict import EasyDict as easydict cfg = easydict()
def get_params(): qpd = get_query_params() or {} pdp = get_postdata_params() or {} return easydict(qpd, **pdp)
def get_query_params(): qs = os.environ.get("QUERY_STRING") return easydict(parse_qs(qs))
def load_cached_issue(issue): fn = issue + ".json" if os.path.exists(fn): return easydict(json.load(open(fn)))
def get_cloud_token_info(token): try: info_b64 = token.split(".")[1] + "=" return easydict(json.loads(base64.urlsafe_b64decode(info_b64))) except: pass
def search_issues(jql, **kw): path = '/rest/api/2/search' jql = jql.replace(" ", "+") e = easydict(jql=jql, maxResults=100, **kw) return call_api(GET, path, e)
def get_user_lookup(): lookup = get_user_lookup_d() items = sorted(lookup.items(), key=operator.itemgetter(1)) return easydict([{'id': k, 'name': v} for k, v in items])