# HG changeset patch # User Franz Glasner # Date 1439558098 -7200 # Node ID 3e0f25b30aaaf3274cc8e9f72af9a37be27a0b61 # Parent fa51898696518e2470b8a3a6f0dea023ddd27dea Module und function to read .hg_archival.txt and frieds and parse it's contents diff -r fa5189869651 -r 3e0f25b30aaa read_revinfo.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/read_revinfo.py Fri Aug 14 15:14:58 2015 +0200 @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +r"""Read the output of the revinfo extension. + +Reads also the contents of a ".hg_archival.txt" file. + +""" + +__version__ = "0" + +__author__ = "Franz Glasner" + + +def read_revinfo(filename): + """Read file file `filename` and return it's contents as dict. + + If `filename` does not exist return `None`. + + """ + try: + with open(filename, "rt") as f: + return dict([[i.strip() for i in line.split(":", 1)] for line in f]) + except EnvironmentError: + return None + +import sys +print read_revinfo(sys.argv[1])