Browse Source

(enissue.py) Fix list mode, including paging through issues or listing and paging through labels (Fix #568).

master
poikilos 3 years ago
parent
commit
e1dd452632
  1. 40
      utilities/enissue.py

40
utilities/enissue.py

@ -949,7 +949,8 @@ class Repo:
''' '''
quiet = options.get('quiet') is True quiet = options.get('quiet') is True
debug("get_issues...") debug("get_issues...")
debug(" options={}".format(options)) # debug(" options={}".format(options))
# ^ By now, options is populated with defaults as well.
debug(" query={}".format(query)) debug(" query={}".format(query))
if query is not None: if query is not None:
for k,v in query.items(): for k,v in query.items():
@ -1046,12 +1047,13 @@ class Repo:
"".format(prev_query_s, url)) "".format(prev_query_s, url))
debug(" (issues will be set to the content of the {}" debug(" (issues will be set to the content of the {}"
" element)".format(results_key)) " element)".format(results_key))
else: # else:
raise ValueError( # raise ValueError(
"The url is unknown for the action." # "The url is unknown for the action."
" Maybe the code is trying to get labels instead" # " Maybe the code is trying to get labels instead"
" of issues and should call _get_labels." # " of issues and should call _get_labels."
) # )
# else issues list, it seems
# Labels are NOT in the URL, but filtered later (See docstring). # Labels are NOT in the URL, but filtered later (See docstring).
@ -1062,7 +1064,8 @@ class Repo:
"".format(query_part, c_path)) "".format(query_part, c_path))
elif len(query_part) > 0: elif len(query_part) > 0:
if url is None: if url is None:
raise RuntimeError("url is None") url = self.issues_url
# raise RuntimeError("url is None")
if query_part is None: if query_part is None:
raise RuntimeError("query_part is None") raise RuntimeError("query_part is None")
url += "?" + query_part url += "?" + query_part
@ -1221,11 +1224,12 @@ class Repo:
return results, None return results, None
def _get_url(self, url, c_path=None): def _get_url(self, url, c_path=None, comment_prefix=""):
''' '''
Keyword arguments: Keyword arguments:
c_path -- If not None, save the results as JSON to this path. c_path -- If not None, save the results as JSON to this path.
''' '''
p = comment_prefix
self.last_src = url self.last_src = url
try: try:
headers = {} headers = {}
@ -1305,7 +1309,7 @@ class Repo:
quiet=quiet, quiet=quiet,
) )
''' '''
result, err = self._get_url(query_url) result, err = self._get_url(query_url, comment_prefix=" * ")
return result, err return result, err
def getCachedJsonDict(self, url, refresh=False, never_expire=False, def getCachedJsonDict(self, url, refresh=False, never_expire=False,
@ -1499,7 +1503,11 @@ class Repo:
if result is not None: if result is not None:
return result, None return result, None
result, err = self._get_url(url, c_path=c_path) result, err = self._get_url(
url,
c_path=c_path,
comment_prefix=" * ",
)
return result, err return result, err
def show_issue(self, issue, refresh=False, never_expire=False, def show_issue(self, issue, refresh=False, never_expire=False,
@ -2177,10 +2185,12 @@ def main():
elif len(match_all_labels) > 1: elif len(match_all_labels) > 1:
mode = "list" mode = "list"
else: else:
raise RuntimeError( mode = "list"
"The command combination is not implemented" debug("* defaulting to list mode (no command)")
" (The mode couldn't be determined)." # raise RuntimeError(
) # "The command combination is not implemented"
# " (The mode couldn't be determined)."
# )
if save_key is not None: if save_key is not None:
raise ValueError("--{} requires a space then a value." raise ValueError("--{} requires a space then a value."
"".format(save_key)) "".format(save_key))

Loading…
Cancel
Save