Last active
August 22, 2019 17:35
-
-
Save jnavila/c2c7ef33d1572d36f7e021b791427c04 to your computer and use it in GitHub Desktop.
pythonesque version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import polib | |
import sys | |
SECTIONS = {300: ["en/git-init.txt", | |
"en/git-clone.txt", | |
"en/urls.txt", | |
"en/git-add.txt"], | |
280: ["en/git-status.txt", | |
"en/git-diff.txt", | |
"en/diff-options.txt", | |
"en/diff-format.txt", | |
"en/git-commit.txt", | |
"en/date-formats.txt", | |
"en/i18n.txt", | |
"en/git-reset.txt", | |
"en/git-rm.txt", | |
"en/git-mv.txt"], | |
260: ["en/git-show.txt", | |
"en/pretty-options.txt", | |
"en/pretty-formats.txt", | |
"en/diff-generate-patch.txt", | |
"en/git-log.txt", | |
"en/line-range-format", | |
"en/rev-list-options.txt", | |
"en/git-shortlog.txt", | |
"en/mailmap.txt", | |
"en/git-describe.txt"], | |
240: ["en/git-branch.txt", | |
"en/git-checkout.txt", | |
"en/git-merge.txt", | |
"en/merge-options.txt", | |
"en/merge-strategies.txt", | |
"en/config/merge.txt", | |
"en/config/fmt-merge-msg.txt", | |
"en/mergetools-merge.txt", | |
"en/git-mergetool.txt", | |
"en/git-stash.txt", | |
"en/git-tag.txt", | |
"en/git-worktree.txt"], | |
220: ["en/git-fetch.txt", | |
"en/fetch-options.txt", | |
"en/pull-fetch-param.txt", | |
"en/urls-remotes.txt", | |
"en/transfer-data-leaks.txt", | |
"en/git-pull.txt", | |
"en/git-push.txt", | |
"en/git-remote.txt", | |
"en/git-submodule.txt"] | |
} | |
def main (f): | |
po = polib.pofile(f, wrapwidth=0) | |
priorities = dict((source, section) for section in SECTIONS for source in SECTIONS[section]) | |
for entry in po: | |
if not entry.obsolete: | |
p = max(priorities.get(filename) or 100 for (filename, _) in entry.occurrences) | |
flags = [f for f in entry.flags if not f.startswith("priority:")] | |
flags.append("priority:{}".format(p)) | |
entry.flags = flags | |
po.save(f) | |
if __name__ == '__main__': | |
if len(sys.argv)>1: | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment