Spage has uploaded a new change for review. https://gerrit.wikimedia.org/r/179057
Change subject: WIP: Trello JSON processing for Phabricator ...................................................................... WIP: Trello JSON processing for Phabricator Currently just outputs fields for the maniphest.createtask conduit. See https://www.mediawiki.org/wiki/Phabricator/Trello_to_Phabricator Change-Id: Ia57b5c034bf58f8f3c502a2fa98ed779c135f1cd --- A trello_create.py 1 file changed, 51 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/phabricator/tools refs/changes/57/179057/1 diff --git a/trello_create.py b/trello_create.py new file mode 100644 index 0000000..4866252 --- /dev/null +++ b/trello_create.py @@ -0,0 +1,51 @@ +# +# Basic processor of Trello board export as JSON file. +# Documentation at https://www.mediawiki.org/wiki/Phabricator/Trello_to_Phabricator +import argparse +import json +import sys + +from phabricator import Phabricator +from wmfphablib import errorlog as elog + +def sanity_check(trello_json, data_file): + if not 'cards' in trello_json: + elog('No cards in input file %s' % (data_file)) + sys.exit(1) + +def create(card): + title = card["name"] + desc = card["desc"] + desc_tail = "\n--------------------------" + desc_tail += "\n**Trello card**: [[ %s | %s ]]" % (card["url"], card["shortLink"]) + full_description = desc + '\n' + desc_tail + print '"%s"\n"%s"\n\n' % (title.encode('unicode-escape'), full_description.encode('unicode-escape')) + + +def process_cards(trello_json): + for card in trello_json["cards"]: + # Skip archived cards ("closed" seems to correspond) + if card["closed"]: + continue + + # TODO: skip cards that are bugs + # skip cards that already exist in Phab. + create(card) + + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument("-v", "--verbose", action="store_true", + help="increase output verbosity") + parser.add_argument("-j", "--json", help="Trello board JSON export file" ) + args = parser.parse_args() + + with open(args.json) as data_file: + trello_json = json.load(data_file) + sanity_check(trello_json, data_file); + + process_cards(trello_json); + +if __name__ == '__main__': + main() -- To view, visit https://gerrit.wikimedia.org/r/179057 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia57b5c034bf58f8f3c502a2fa98ed779c135f1cd Gerrit-PatchSet: 1 Gerrit-Project: phabricator/tools Gerrit-Branch: master Gerrit-Owner: Spage <sp...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits