Changeset e1346e2 in rtems-source-builder
- Timestamp:
- 01/18/18 03:35:31 (6 years ago)
- Branches:
- 4.11
- Children:
- 2ac145a
- Parents:
- f7c729e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source-builder/sb/path.py
rf7c729e re1346e2 54 54 return path 55 55 56 def is_abspath(path): 57 if path is not None: 58 return '/' == path[0] 59 return False 60 56 61 def shell(path): 57 62 if path is not None: … … 68 73 69 74 def basename(path): 70 return shell(os.path.basename(path)) 75 path = shell(path) 76 return shell(os.path.basename(host(path))) 71 77 72 78 def dirname(path): 79 path = shell(path) 73 80 return shell(os.path.dirname(path)) 74 81 … … 83 90 84 91 def abspath(path): 92 path = shell(path) 85 93 return shell(os.path.abspath(host(path))) 86 94 95 def relpath(path, start = None): 96 path = shell(path) 97 if start is None: 98 path = os.path.relpath(host(path)) 99 else: 100 path = os.path.relpath(host(path), start) 101 return shell(path) 102 87 103 def splitext(path): 104 path = shell(path) 88 105 root, ext = os.path.splitext(host(path)) 89 106 return shell(root), ext 90 107 91 108 def listdir(path): 109 path = shell(path) 92 110 hp = host(path) 93 111 if not os.path.exists(hp): … … 97 115 def exists(paths): 98 116 def _exists(p): 99 return os.path.basename(p) in listdir(dirname(p)) 117 if not is_abspath(p): 118 p = shell(join(os.getcwd(), host(p))) 119 return basename(p) in ['.'] + listdir(dirname(p)) 100 120 101 121 if type(paths) == list: 102 122 results = [] 103 123 for p in paths: 104 results += [_exists( p)]124 results += [_exists(shell(p))] 105 125 return results 106 return _exists( paths)126 return _exists(shell(paths)) 107 127 108 128 def isdir(path): 129 path = shell(path) 109 130 return os.path.isdir(host(path)) 110 131 111 132 def isfile(path): 133 path = shell(path) 112 134 return os.path.isfile(host(path)) 113 135 114 136 def isabspath(path): 137 path = shell(path) 115 138 return path[0] == '/' 116 139 117 140 def iswritable(path): 141 path = shell(path) 118 142 return os.access(host(path), os.W_OK) 119 143 120 144 def ispathwritable(path): 121 path = host(path)145 path = shell(path) 122 146 while len(path) != 0: 123 147 if exists(path): 124 148 return iswritable(path) 125 path = os.path.dirname(path)149 path = dirname(path) 126 150 return False 127 151 128 152 def mkdir(path): 129 path = host(path)153 path = shell(path) 130 154 if exists(path): 131 155 if not isdir(path): … … 150 174 151 175 def chdir(path): 176 path = shell(path) 152 177 os.chdir(host(path)) 153 178 … … 186 211 _remove_node(dir) 187 212 213 path = shell(path) 188 214 hpath = host(path) 189 215 … … 193 219 194 220 def expand(name, paths): 221 path = shell(path) 195 222 l = [] 196 223 for p in paths: 197 l += [join( p, name)]224 l += [join(shell(p), name)] 198 225 return l 199 226 200 227 def copy(src, dst): 228 src = shell(src) 229 dst = shell(dst) 201 230 hsrc = host(src) 202 231 hdst = host(dst) … … 208 237 pass 209 238 else: 210 raise error.general('copying tree : %s -> %s: %s' % (hsrc, hdst, str(why)))239 raise error.general('copying tree (1): %s -> %s: %s' % (hsrc, hdst, str(why))) 211 240 212 241 def copy_tree(src, dst): … … 216 245 hdst = host(dst) 217 246 218 if exists( hsrc):219 names = listdir( hsrc)247 if exists(src): 248 names = listdir(src) 220 249 else: 221 250 names = [] … … 244 273 if os.path.islink(srcname): 245 274 linkto = os.readlink(srcname) 246 if exists( dstname):275 if exists(shell(dstname)): 247 276 if os.path.islink(dstname): 248 277 dstlinkto = os.readlink(dstname) … … 263 292 shutil.copystat(host(srcname), host(dstname)) 264 293 except shutil.Error as err: 265 raise error.general('copying tree : %s -> %s: %s' % \294 raise error.general('copying tree (2): %s -> %s: %s' % \ 266 295 (hsrc, hdst, str(err))) 267 296 except EnvironmentError as why: 268 raise error.general('copying tree : %s -> %s: %s' % \297 raise error.general('copying tree (3): %s -> %s: %s' % \ 269 298 (srcname, dstname, str(why))) 270 299 try: … … 275 304 pass 276 305 else: 277 raise error.general('copying tree : %s -> %s: %s' % (hsrc, hdst, str(why)))306 raise error.general('copying tree (4): %s -> %s: %s' % (hsrc, hdst, str(why))) 278 307 279 308 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.