python-dev-tools / pydtl-relativepath

pydtl-relativepath tool from pydtl community can be used to solve many issues that occurs with relative paths and imports from various modules in your complex framework.
MIT License
0 stars 0 forks source link

pathlib objext does not work with normal string operations #15

Open NanthagopalEswaran opened 3 months ago

NanthagopalEswaran commented 3 months ago

Checked other resources

Description

After constructing the path, I am trying to parse and check if it is an Excel file. the logic for that is developed in normal string manipulations.

Reproduce Steps

sample code:

test_plan_path = rel2abs(
    "data/Testplan.xlsx",
    relative_type=RelativePathType.RELATIVE_TO_WORKING_DIRECTORY,
    parent_dir_jump=-2,
)

test_plan_path.endswith(".xlsx")

Error Message and Stack Trace (if applicable)

def _validate_path(self, path: str):
     if not os.path.isfile(path):
          raise FileNotFoundError(f"File not found at path: {path}")
     if not path.endswith(".xlsx"):
          raise ValueError("File should be in Excel format")

Error : FileNotFoundError: File not found at path: "<folder>Testplan.xlsx"

System Info

Windows 10 python version: 3.11.6 (64-bit) pydtl-relative_path: 0.2.0