import os

# os.path.dirname(os.path.abspath(__file__)) # directory of the script being run

os.getcwd()

print(os.path.abspath("../../../../"))
# os.listdir(os.path.abspath("../../../../"))

print(os.path.isdir(os.path.abspath("../../../../") + "/tdms/"))
os.listdir(os.path.abspath("../../../../") + "/tdms/")

tdms_test_fixtures_path = os.path.abspath("../../../../") + "/tdms/test/fixtures/"

for file in os.listdir(tdms_test_fixtures_path):
    if file.endswith(".tdms"):
        print(file)

"""
Explanation: From .tdms
Sanity check of file/path location
End of explanation
"""


import nptdms
from nptdms import TdmsFile

example_tdms_file = TdmsFile(tdms_test_fixtures_path + "example.tdms")
print(type(example_tdms_file))
print(dir(example_tdms_file))
#example_channel = example_tdms_file.object('Group', 'Channel1')
#data = channel.data

"""
Explanation: Typical read usage
cf. https://nptdms.readthedocs.io/en/latest/quickstart.html
End of explanation
"""


print(type(example_tdms_file.objects))
print(dir(example_tdms_file.objects))
print(example_tdms_file.objects.keys())

"""
Explanation: cf. https://nptdms.readthedocs.io/en/latest/apireference.html
objects – A dictionary of objects in the TDMS file, where the keys are the object paths.
End of explanation
"""


print(os.path.abspath(os.getcwd()))

example_tdms_file = TdmsFile(tdms_test_fixtures_path + "example.tdms", os.path.abspath(os.getcwd()) + "/tempdata/")

print(example_tdms_file.memmap_dir)

"""
Explanation: With memmap
__init__(file, memmap_dir=None)
Initialise a new TDMS file object, reading all data.
memmap_dir – The directory to store memmapped data files in, or None to read data into memory. The data files are created as temporary files and are deleted when the channel data is no longer used. tempfile.gettempdir() can be used to get the default temporary file directory.
End of explanation
"""


print(example_tdms_file.groups())

"""
Explanation: cf. https://nptdms.readthedocs.io/en/latest/apireference.html
object(*path)
Get a TDMS object from a file.
.groups
Return the names of groups in the file.
End of explanation
"""


