walk in paths and do different actions for each file
Fri Aug 27 2021 08:14:08 GMT+0000 (Coordinated Universal Time)
Saved by
@juferreira
#python
#walk
#ifelse
#compare
#comparestrings
full_path_for_helm_values_china="/Users/julianaferreira/repos/helm-charts/deploy-global/values/services/live-china"
import os
for root, dirs, files in os.walk(full_path_for_helm_values_china, topdown=False):
for name in files:
file_path=os.path.join(root, name)
file_name=os.path.join(root, name).split("/")[-1].split(".")[0]
if file_name in "public-pages":
print("1")
print (file_name)
#elif file_name in "nginx-gateway":
# in check if file_name exists in string "nginx-gateway". Just "nginx" or "gateway" are true too.
elif file_name == "nginx-gateway":
## == compara exacly string with file_name
#elif file_name.__contains__("nginx-gateway"):
# contains check if string "nginx-gateway" exists in file_name. Return true just for *"nginx-gateway"*.
print("2")
print (file_name)
else:
print("3")
print (file_name)
content_copyCOPY
Comments