Created
June 19, 2020 13:03
-
-
Save easternnl/b2a1380013eea990db7413de8b58d4fe to your computer and use it in GitHub Desktop.
Python file list convert to JSON with MTime included (and other properties if needed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, json | |
class FileItem(dict): | |
def __init__(self, name): | |
dict.__init__(self, name=name) | |
dict.__init__(self, mtime=os.path.getmtime(name)) # get the modify time | |
my_objects = [] | |
for root, dirs, files in os.walk("./JMeterReplaceAllVariabelesInVar/", topdown=False): | |
files = [ fi for fi in files if fi.endswith(".groovy") ] | |
for name in files: | |
#print(os.path.join(root, name)) | |
my_objects.append(FileItem(os.path.join(root, name))) | |
#for name in dirs: | |
# print(os.path.join(root, name)) | |
#a = my_objects.toJSON | |
a = json.dumps(my_objects) | |
print("Wait") | |
# later | |
for obj in my_objects: | |
print (obj['fname']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment