annotate read_revinfo.py @ 5:3e0f25b30aaa

Module und function to read .hg_archival.txt and frieds and parse it's contents
author Franz Glasner <hg@dom66.de>
date Fri, 14 Aug 2015 15:14:58 +0200
parents
children 538c8f20ed51
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
2 r"""Read the output of the revinfo extension.
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
3
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
4 Reads also the contents of a ".hg_archival.txt" file.
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
5
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
6 """
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
7
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
8 __version__ = "0"
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
9
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
10 __author__ = "Franz Glasner"
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
11
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
12
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
13 def read_revinfo(filename):
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
14 """Read file file `filename` and return it's contents as dict.
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
15
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
16 If `filename` does not exist return `None`.
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
17
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
18 """
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
19 try:
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
20 with open(filename, "rt") as f:
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
21 return dict([[i.strip() for i in line.split(":", 1)] for line in f])
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
22 except EnvironmentError:
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
23 return None
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
24
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
25 import sys
3e0f25b30aaa Module und function to read .hg_archival.txt and frieds and parse it's contents
Franz Glasner <hg@dom66.de>
parents:
diff changeset
26 print read_revinfo(sys.argv[1])