import sys import yaml with open(sys.argv[1]) as fp: data = fp.read() if not data.find("---") == 0: # no head print("NO YAML HEAD FOUND") sys.exit(-1) data = data[3:] head_end = data.find("---") head = data[0:head_end] data = data[head_end+3:] metadata = yaml.safe_load(head) cats = metadata.pop('categories', None) if cats != None: if type(cats) == list: tags = cats elif type(cats) == str: tags = cats.split() tags = list(map(lambda t: t.lower(), tags)) metadata["tags"] = ", ".join(tags) new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}" # write it print(f"coverted: categories to tags: {tags} - {sys.argv[1]}") with open(sys.argv[1], "w") as fp: fp.write(new_data) sys.exit(0) if not metadata.get("tags", None): metadata["tags"] = "untagged" new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}" print(f"untagged: {sys.argv[1]}") # write it with open(sys.argv[1], "w") as fp: fp.write(new_data) sys.exit(0) print("No changes needed")
2.4 KiB
author | comments | date | layout | slug | tags | title | wordpress_id |
---|---|---|---|---|---|---|---|
dhananjayishere | true | 2012-03-18 02:56:00 | post | progress-bar-in-mercurial-pushpull | free software, programing, revision control | Progress bar in mercurial push/pull | 112432788 |
I admit I am a huge Git fanatic. Infact I havent used anything else for managing the code (except some checkout from svn). I was trying to build orange, so I wasnt very happy when I realised they use mercurial for the revision control (I, like all my fellow programmers is a lazy person to adapt ;-) ).
The first problem I faced was when cloning the code (checkout, subversion guys!), by default mecurial doesnt give you any progress dialogs. It can get frustrating if you are cloning a substantially large repository. Good thing is mercurial from 1.5 onwards contains an extensoin for doing this, called progress. Only thng is you have to enable it explicitly.
Note that as per the mercurial documentation,system wide hg configuration file is stored in any of the following paths,
(Unix) /etc/mercurial/hgrc
or
/etc/mercurial/hgrc.d/*.rc
(Windows) Mercurial.ini or(Windows) hgrc.d*.rc
or
HKEY_LOCAL_MACHINESOFTWAREMercurial
and repositroy specific configuration in
/.hg/hgrc [ from man hgrc ]
To enable the progress extention, Create the file if it doesnt exist and add the fllowing to it.
[extensions]progress =
This enables the progress extention. You can define the configuration specific to this extention, by creating a sperate section in hgrc named [progress]. Information about thease options can be obtained by executing
[dhananjay@dlab orange]$ hg help progress|head
progress extension - show progress bars for some actionsThis extension uses the progress information logged by hg commands to drawprogress bars that are as informative as possible. Some progress bars onlyoffer indeterminate information, while others have a definite end point...
For example if you want a progress bar with refresh time 05 second, your hgrc should be like this,
[dhananjay@dlab orange]$ cat ~/.hgrc
[extensions]
progress =
[progress]
refresh = 0.5
Note: This blog is heavily inspired from http://stackoverflow.com/questions/308491/show-progress-of-mercurial-push-pull.