-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_path.py
More file actions
34 lines (28 loc) · 960 Bytes
/
Copy pathtest_path.py
File metadata and controls
34 lines (28 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def removePathVariable(path):
finish = path.find('}')
return path[finish+1:len(path)]
import os
# Get the list of all files and directories
path = "C:\\Users\\anuch\\Downloads\\pentaho_jobs_and_transformations\\pentaho_jobs_and_transformations\\jobs"
dir_list = os.listdir(path)
print("Files and directories in '", path, "' :")
fileNames = []
for name in dir_list:
if name.endswith(".kjb"):
fileNames.append(name)
print(name)
def removeVariable(path, dict):
startIndex = path.find('{')
if startIndex != -1:
print(startIndex)
finishIndex = path.find('}')
key = path[startIndex+1:finishIndex]
value = dict.get(key)
path = path.replace("{"+key+"}",value)
return path
hash = {}
path = "C:\\Users\\anuch\\Downloads\\pentaho_jobs_and_transformations\\pentaho_jobs_and_transformations\\{database}"
key = "database"
value = "taut"
hash[key] = value
print(removeVariable(path,hash))