|
@ -165,6 +165,11 @@ def usage(): |
|
|
print(" "*(left_w+len(spacer)+2) + "./" + me + s) |
|
|
print(" "*(left_w+len(spacer)+2) + "./" + me + s) |
|
|
print("") |
|
|
print("") |
|
|
print("") |
|
|
print("") |
|
|
|
|
|
print("") |
|
|
|
|
|
print("Options:") |
|
|
|
|
|
print("--cache-base <dir> Set the directory for cached files.") |
|
|
|
|
|
print("--verbose Enable verbose mode.") |
|
|
|
|
|
print("--debug Enable verbose mode (same as --debug).") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Repo: |
|
|
class Repo: |
|
@ -174,9 +179,6 @@ class Repo: |
|
|
else: |
|
|
else: |
|
|
profile = os.environ['HOME'] |
|
|
profile = os.environ['HOME'] |
|
|
|
|
|
|
|
|
caches_path = os.path.join(profile, ".cache", "enissue") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
def __init__( |
|
|
self, |
|
|
self, |
|
|
remote_user = "poikilos", |
|
|
remote_user = "poikilos", |
|
@ -191,6 +193,7 @@ class Repo: |
|
|
c_issue_name_fmt = "{issue_no}.json", |
|
|
c_issue_name_fmt = "{issue_no}.json", |
|
|
default_query = {'state':'open'}, |
|
|
default_query = {'state':'open'}, |
|
|
hide_events = ['renamed', 'assigned'], |
|
|
hide_events = ['renamed', 'assigned'], |
|
|
|
|
|
caches_path=None, |
|
|
): |
|
|
): |
|
|
''' |
|
|
''' |
|
|
Keyword arguments: |
|
|
Keyword arguments: |
|
@ -218,16 +221,25 @@ class Repo: |
|
|
search_results_key -- If the URL described by |
|
|
search_results_key -- If the URL described by |
|
|
search_issues_url_fmt returns a dict, specify the key in |
|
|
search_issues_url_fmt returns a dict, specify the key in |
|
|
the dict that is a list of issues. |
|
|
the dict that is a list of issues. |
|
|
|
|
|
caches_path -- Store cached json files here: Specifically, in an |
|
|
|
|
|
"issues" directory or other directory under the user and |
|
|
|
|
|
repo directory. For example, if caches_path is None and uses |
|
|
|
|
|
the default ~/.cache/enissue, the numbered json files |
|
|
|
|
|
(and numbered folders containing timeline.json or other |
|
|
|
|
|
connected data) for issues will appear in |
|
|
|
|
|
"~/.cache/enissue/poikilos/EnlivenMinetest/issues". To set |
|
|
|
|
|
it later, use the setCachesPath method. |
|
|
''' |
|
|
''' |
|
|
self.search_results_key = search_results_key |
|
|
if caches_path is None: |
|
|
self.page = None |
|
|
caches_path = os.path.join(Repo.profile, ".cache", |
|
|
|
|
|
"enissue") |
|
|
self.remote_user = remote_user |
|
|
self.remote_user = remote_user |
|
|
self.repo_name = repo_name |
|
|
self.repo_name = repo_name |
|
|
|
|
|
self.setCachesPath(caches_path) |
|
|
|
|
|
|
|
|
|
|
|
self.search_results_key = search_results_key |
|
|
|
|
|
self.page = None |
|
|
self.repository_id = repository_id |
|
|
self.repository_id = repository_id |
|
|
self.c_remote_user_path = os.path.join(Repo.caches_path, |
|
|
|
|
|
self.remote_user) |
|
|
|
|
|
self.c_repo_path = os.path.join(self.c_remote_user_path, |
|
|
|
|
|
self.repo_name) |
|
|
|
|
|
self.c_issue_name_fmt = c_issue_name_fmt |
|
|
self.c_issue_name_fmt = c_issue_name_fmt |
|
|
self.api_repo_url_fmt = api_repo_url_fmt |
|
|
self.api_repo_url_fmt = api_repo_url_fmt |
|
|
self.api_issue_url_fmt = api_issue_url_fmt |
|
|
self.api_issue_url_fmt = api_issue_url_fmt |
|
@ -251,6 +263,19 @@ class Repo: |
|
|
self.hide_events = hide_events |
|
|
self.hide_events = hide_events |
|
|
self.issues = None |
|
|
self.issues = None |
|
|
|
|
|
|
|
|
|
|
|
def setCachesPath(self, caches_path): |
|
|
|
|
|
''' |
|
|
|
|
|
This directory will contain <remote_user>/<repo_name>/ |
|
|
|
|
|
which will contain issues/ and potentially other directories |
|
|
|
|
|
that mimic the API web URL structure (See _get_issues code for |
|
|
|
|
|
subdirectories and files). |
|
|
|
|
|
''' |
|
|
|
|
|
self.caches_path = caches_path |
|
|
|
|
|
self.c_remote_user_path = os.path.join(self.caches_path, |
|
|
|
|
|
self.remote_user) |
|
|
|
|
|
self.c_repo_path = os.path.join(self.c_remote_user_path, |
|
|
|
|
|
self.repo_name) |
|
|
|
|
|
|
|
|
def _get_issues(self, options, query=None, issue_no=None, |
|
|
def _get_issues(self, options, query=None, issue_no=None, |
|
|
search_terms=[]): |
|
|
search_terms=[]): |
|
|
''' |
|
|
''' |
|
@ -424,7 +449,7 @@ class Repo: |
|
|
results = [result] |
|
|
results = [result] |
|
|
for issue in results: |
|
|
for issue in results: |
|
|
issue_n = issue.get("number") |
|
|
issue_n = issue.get("number") |
|
|
debug("issue_n: {}".format(issue_n)) |
|
|
# debug("issue_n: {}".format(issue_n)) |
|
|
if issue_n is not None: |
|
|
if issue_n is not None: |
|
|
if (max_issue is None) or (issue_n > max_issue): |
|
|
if (max_issue is None) or (issue_n > max_issue): |
|
|
max_issue = issue_n |
|
|
max_issue = issue_n |
|
@ -482,7 +507,7 @@ class Repo: |
|
|
def getCachedJsonDict(self, url, refresh=False): |
|
|
def getCachedJsonDict(self, url, refresh=False): |
|
|
''' |
|
|
''' |
|
|
This gets the cached page using the cache location |
|
|
This gets the cached page using the cache location |
|
|
cache directory specified in Repo.caches_path and further |
|
|
cache directory specified in self.caches_path and further |
|
|
narrowed down to self.c_repo_path then narrowed down using the |
|
|
narrowed down to self.c_repo_path then narrowed down using the |
|
|
URL. For example, https://api.github.com/repos/poikilos/EnlivenMinetest/issues?q=page:1 |
|
|
URL. For example, https://api.github.com/repos/poikilos/EnlivenMinetest/issues?q=page:1 |
|
|
|
|
|
|
|
@ -942,6 +967,7 @@ def main(): |
|
|
options = {} |
|
|
options = {} |
|
|
search_terms = [] |
|
|
search_terms = [] |
|
|
SEARCH_COMMANDS = ['find', 'AND'] |
|
|
SEARCH_COMMANDS = ['find', 'AND'] |
|
|
|
|
|
caches_path = None |
|
|
for i in range(1, len(sys.argv)): |
|
|
for i in range(1, len(sys.argv)): |
|
|
arg = sys.argv[i] |
|
|
arg = sys.argv[i] |
|
|
isValue = False |
|
|
isValue = False |
|
@ -991,6 +1017,9 @@ def main(): |
|
|
elif arg == "--help": |
|
|
elif arg == "--help": |
|
|
usage() |
|
|
usage() |
|
|
exit(0) |
|
|
exit(0) |
|
|
|
|
|
elif arg == "--cache-base": |
|
|
|
|
|
pass |
|
|
|
|
|
# options['caches_path'] = None |
|
|
elif arg.startswith("--"): |
|
|
elif arg.startswith("--"): |
|
|
usage() |
|
|
usage() |
|
|
error("Error: The argument \"{}\" is not valid" |
|
|
error("Error: The argument \"{}\" is not valid" |
|
@ -999,6 +1028,8 @@ def main(): |
|
|
elif prev_arg in SEARCH_COMMANDS: |
|
|
elif prev_arg in SEARCH_COMMANDS: |
|
|
search_terms.append(arg) |
|
|
search_terms.append(arg) |
|
|
isValue = True |
|
|
isValue = True |
|
|
|
|
|
elif prev_arg == "--cache-base": |
|
|
|
|
|
caches_path = arg |
|
|
elif arg == "find": |
|
|
elif arg == "find": |
|
|
# print("* adding criteria: {}".format(arg)) |
|
|
# print("* adding criteria: {}".format(arg)) |
|
|
mode = "list" |
|
|
mode = "list" |
|
@ -1057,6 +1088,10 @@ def main(): |
|
|
sys.exit(1) |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
print("") |
|
|
print("") |
|
|
|
|
|
if caches_path is not None: |
|
|
|
|
|
repo.setCachesPath(caches_path) |
|
|
|
|
|
debug("The cache is now at {}" |
|
|
|
|
|
"".format(repo.c_repo_path)) |
|
|
# print("Loading...") |
|
|
# print("Loading...") |
|
|
|
|
|
|
|
|
# TODO: get labels another way, and make this conditional: |
|
|
# TODO: get labels another way, and make this conditional: |
|
|