# Path: praatio/data_classes/data_point.py
# class PointObject1D(PointObject):
#     """Points that only carry temporal information"""
# 
#     def __init__(
#         self,
#         pointList: List[Tuple[float]],
#         objectClass: Literal["point"],
#         minTime: float = 0,
#         maxTime: Optional[float] = None,
#     ):
# 
#         suitable1dPointTypes = [constants.DataPointTypes.POINT]
#         if objectClass not in suitable1dPointTypes:
#             raise errors.WrongOption("objectClass", objectClass, suitable1dPointTypes)
# 
#         if maxTime is None:
#             maxTime = max([row[0] for row in pointList])
# 
#         castPointList = cast(List[Tuple[float, ...]], pointList)
#         super(PointObject1D, self).__init__(
#             castPointList, objectClass, minTime, maxTime
#         )
# 
# class PointObject2D(PointObject):
#     """Points that carry a temporal value and some other value"""
# 
#     def __init__(
#         self,
#         pointList: List[Tuple[float, float]],
#         objectClass: Literal["pitch", "duration"],
#         minTime: float = 0,
#         maxTime: float = None,
#     ):
#         suitable2dPointTypes = [
#             constants.DataPointTypes.PITCH,
#             constants.DataPointTypes.DURATION,
#         ]
#         if objectClass not in suitable2dPointTypes:
#             raise errors.WrongOption(
#                 "objectClass",
#                 objectClass,
#                 suitable2dPointTypes,
#             )
# 
#         if maxTime is None:
#             maxTime = max([timeV for timeV, _ in pointList])
# 
#         castPointList = cast(List[Tuple[float, ...]], pointList)
#         super(PointObject2D, self).__init__(
#             castPointList, objectClass, minTime, maxTime
#         )


import io
from typing import Tuple
from praatio.data_classes.data_point import PointObject1D, PointObject2D
Code for reading, writing, and representing less complicated praat data files

see **examples/get_vowel_points.py**
"""




def open1DPointObject(fn: str) -> PointObject1D:
    with io.open(fn, "r", encoding="utf-8") as fd:
        data = fd.read()
    if "xmin" in data[:100]:  # Kindof lazy
        data, objectType, minT, maxT = _parseNormalHeader(fn)

        start = 0
        dataList = []
        while True:
            try:
                start = data.index("=", start)
            except ValueError:
                break

            pointVal, start = _getNextValue(data, start)
            dataList.append((float(pointVal),))

        po = PointObject1D(dataList, objectType, minT, maxT)

    else:
        data, objectType, minT, maxT = _parseShortHeader(fn)
        dataList = [(float(val),) for val in data.split("\n") if val.strip() != ""]

# Path: praatio/data_classes/data_point.py
# class PointObject1D(PointObject):
#     """Points that only carry temporal information"""
# 
#     def __init__(
#         self,
#         pointList: List[Tuple[float]],
#         objectClass: Literal["point"],
#         minTime: float = 0,
#         maxTime: Optional[float] = None,
#     ):
# 
#         suitable1dPointTypes = [constants.DataPointTypes.POINT]
#         if objectClass not in suitable1dPointTypes:
#             raise errors.WrongOption("objectClass", objectClass, suitable1dPointTypes)
# 
#         if maxTime is None:
#             maxTime = max([row[0] for row in pointList])
# 
#         castPointList = cast(List[Tuple[float, ...]], pointList)
#         super(PointObject1D, self).__init__(
#             castPointList, objectClass, minTime, maxTime
#         )
# 
# class PointObject2D(PointObject):
#     """Points that carry a temporal value and some other value"""
# 
#     def __init__(
#         self,
#         pointList: List[Tuple[float, float]],
#         objectClass: Literal["pitch", "duration"],
#         minTime: float = 0,
#         maxTime: float = None,
#     ):
#         suitable2dPointTypes = [
#             constants.DataPointTypes.PITCH,
#             constants.DataPointTypes.DURATION,
#         ]
#         if objectClass not in suitable2dPointTypes:
#             raise errors.WrongOption(
#                 "objectClass",
#                 objectClass,
#                 suitable2dPointTypes,
#             )
# 
#         if maxTime is None:
#             maxTime = max([timeV for timeV, _ in pointList])
# 
#         castPointList = cast(List[Tuple[float, ...]], pointList)
#         super(PointObject2D, self).__init__(
#             castPointList, objectClass, minTime, maxTime
#         )


# Path: praatio/data_points.py
import io
from typing import Tuple
from praatio.data_classes.data_point import PointObject1D, PointObject2D

Code for reading, writing, and representing less complicated praat data files

see **examples/get_vowel_points.py**
"""




def open1DPointObject(fn: str) -> PointObject1D:
    with io.open(fn, "r", encoding="utf-8") as fd:
        data = fd.read()
    if "xmin" in data[:100]:  # Kindof lazy
        data, objectType, minT, maxT = _parseNormalHeader(fn)

        start = 0
        dataList = []
        while True:
            try:
                start = data.index("=", start)
            except ValueError:
                break

            pointVal, start = _getNextValue(data, start)
            dataList.append((float(pointVal),))

        po = PointObject1D(dataList, objectType, minT, maxT)

    else:
        data, objectType, minT, maxT = _parseShortHeader(fn)
        dataList = [(float(val),) for val in data.split("\n") if val.strip() != ""]

        po = PointObject1D(dataList, objectType, minT, maxT)