1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from __future__ import print_function
25 import os, sys, re, json, time, argparse
26 dirNm, execName = os.path.split(os.path.realpath(sys.argv[0]))
27 sys.path.append(os.path.realpath(os.path.join(dirNm, "../libexec")))
28 sys.path.append(os.path.realpath(os.path.join(dirNm, "../site")))
29
31 """ This class files the reverseMap File from the reverse map directory"""
33 """
34 This ctor opens the reverse map directory. It looks for a file named
35 "jsonReverseMapT.json". If that file is not found it looks for
36 "jsonReverseMapT.old.json". The file is read in and converted to a
37 python table. The contents contain a timestampfn key value pair.
38
39 The reverse map table is return in all cases except when the timestamp
40 file exists and is newer than the reverseMap file.
41
42 @param rmapD: The reverse map directory
43 """
44 self.__rmapT = {}
45 if (not rmapD):
46 return
47 rmapA = rmapD.split(':')
48 searchA = [ ".json", ".old.json"]
49 rmapFn = None
50 for dir in rmapA:
51 for ext in searchA:
52 rmapFn = os.path.join(dir, "jsonReverseMapT" + ext)
53 if (os.access(rmapFn, os.R_OK)):
54 break
55 if (rmapFn):
56 rmpMtime = os.stat(rmapFn).st_mtime
57 f = open(rmapFn,"r")
58 t = json.loads(f.read())
59 f.close()
60 tsFn = t.get('timestampFn')
61 if (tsFn):
62 tsMtime = os.stat(tsFn).st_mtime
63 if (rmpMtime >= tsMtime):
64 self.__rmapT = t['reverseMapT']
65 else:
66 self.__rmapT = t['reverseMapT']
67
68
70 """
71 return the reverse map table found by the ctor.
72
73 @return reverseMapT
74 """
75 return self.__rmapT
76