]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Python/WorkspaceRoutines.py
3634d256617d0ec8aed7c205cca39fe136f5a161
[mirror_edk2.git] / Tools / Python / WorkspaceRoutines.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2007, Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 import os, sys, re, getopt, string, glob, xml.dom.minidom, pprint, md5, socket, getpass, time, random
13
14 def inWorkspace(rel_path=""):
15 """Treat the given path as relative to the workspace."""
16
17 # Make sure the user has set the workspace variable:
18 try:
19 return os.path.join(os.environ["WORKSPACE"], rel_path )
20 except:
21 print "Oops! You must set the WORKSPACE environment variable to run this script."
22 sys.exit()
23
24 def genguid():
25 g = md5.md5(
26 str(random.random()) +
27 getpass.getuser() +
28 str(time.time()) +
29 socket.gethostbyname(socket.gethostname())).hexdigest()
30 return "%s-%s-%s-%s-%s" % (g[0:8], g[8:12], g[12:16], g[16:20], g[20:])
31
32 def lean(path):
33 """Lean the slashes forward"""
34
35 return os.path.normpath(path).replace("\\", "/")