From b407d1c95b58b728ad97af01bbb639153e118abb Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 10 Oct 2015 01:37:38 +0200 Subject: [PATCH 1/4] [mod] reorder entries in community.json because it's not sorted correctly --- community.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/community.json b/community.json index 924a1bed..1e4ff0b5 100644 --- a/community.json +++ b/community.json @@ -1,16 +1,16 @@ { - "243": { - "branch": "master", - "revision": "b9d58efeac78feb7f74e723c999ff25ab7ab8b52", - "state": "ready", - "url": "https://github.com/M5oul/243_ynh" - }, "20euros": { "branch": "master", "revision": "c8d5fadc9f042a92f14b753eff3ffc948322cf2d", "state": "ready", "url": "https://github.com/M5oul/20euros_ynh" }, + "243": { + "branch": "master", + "revision": "b9d58efeac78feb7f74e723c999ff25ab7ab8b52", + "state": "ready", + "url": "https://github.com/M5oul/243_ynh" + }, "adhocserver": { "branch": "master", "revision": "d1a728b9b99608bac69b55372cddf1aa3f4a5557", From 7de9c3d4e6004033da68bde7fb92af9ee407ea40 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 10 Oct 2015 01:37:57 +0200 Subject: [PATCH 2/4] [enh] add script for super lazy people like me --- add_or_update.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 add_or_update.py diff --git a/add_or_update.py b/add_or_update.py new file mode 100644 index 00000000..603e410b --- /dev/null +++ b/add_or_update.py @@ -0,0 +1,64 @@ +import os +import sys +import json + +from urllib2 import urlopen + +states = { + 1: "notworking", + 2: "inprogress", + 3: "working", +} + +if __name__ == '__main__': + if not len(sys.argv[1:]): + print("I need a json file as first argument and a list of github urls") + sys.exit(0) + + if len(sys.argv[1:]) < 2: + print("I need a list of github urls after the json file") + sys.exit(0) + + if not os.path.exists(sys.argv[1]): + print("The json file '%s' doesn't exist" % sys.argv[1]) + + content = json.load(open(sys.argv[1], "r")) + + for url in sys.argv[2:]: + if not url.startswith("https://github.com"): + sys.stderr.write("WARNING: url '%s' doesn't starts with https://github.com, skip it\n" % url) + + owner, repo = filter(None, url.split("/"))[-2:] + project_name = filter(None, url.split("/"))[-1].replace("_ynh", "") + + github_data = json.load(urlopen("https://api.github.com/repos/%(owner)s/%(repo)s/commits" % {"owner": owner, "repo": repo})) + + if project_name not in content: + content[project_name] = {} + else: + print("INFO: project already in '%s', I'm updating it" % sys.argv[1]) + + content[project_name]["url"] = url + content[project_name]["revision"] = github_data[0]["sha"] + content[project_name]["branch"] = "master" + + if sys.argv[1] == "official.json": + content[project_name]["state"] = "validated" + + else: + got_state = False + while not got_state: + answer = input("Give me a state for this repository (digit or name) in:\n%s\n\nState: " % "\n".join(["%s: %s" % x for x in sorted(states.items(), key=lambda x: x[0])]) + "\n") + + if answer in states: + answer = states[answer] + got_state = True + elif answer in states.values(): + got_state = True + else: + print("Invalid state.\n") + + content[project_name]["state"] = answer + + open(sys.argv[1], "w").write("\n".join(json.dumps(content, indent=4, sort_keys=True).split(" \n")) + "\n") + os.system("git diff") From a7a9357d87bc5774a224f99ccba26f0db44f9b84 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 10 Oct 2015 01:38:42 +0200 Subject: [PATCH 3/4] [doc] remove invalid markdown --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 668fa7dd..e9fabd65 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,5 @@ The integration will be discussed on the Pull Request. **Important**: You will have to find a maintainer willing to take care of the package while published if you want your app to be validated. ---- - #### More information on [yunohost.org/packaging_apps](https://yunohost.org/packaging_apps) From 243deca5ede6eb4d5f38e7413f6023c05c90cc0c Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 10 Oct 2015 01:40:58 +0200 Subject: [PATCH 4/4] [doc] document the usage of add_or_update.py script --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9fabd65..a722f3ac 100644 --- a/README.md +++ b/README.md @@ -61,5 +61,15 @@ The integration will be discussed on the Pull Request. **Important**: You will have to find a maintainer willing to take care of the package while published if you want your app to be validated. -#### More information on [yunohost.org/packaging_apps](https://yunohost.org/packaging_apps) +#### Helper script +You can use the add_or_update.py python script to add or update +your app from one of the 2 json files. + +Usage: + +```bash +python ./add_or_update.py [community.json OR official.json] [github url [github url [github url ...]]] +``` + +#### More information on [yunohost.org/packaging_apps](https://yunohost.org/packaging_apps)