예제 #1
0
파일: pyContrReader.py 프로젝트: jgu2/PyDSS
    def __init__(self, filePath):
        self.pyControllers = {}
        self.publicationList = []
        xlsx_filename = os.path.splitext(filePath)[0] + '.xlsx'
        if not os.path.exists(filePath) and os.path.exists(xlsx_filename):
            convert_config_data_to_toml(xlsx_filename)

        if not os.path.exists(filePath):
            raise FileNotFoundError(
                'path: "{}" does not exist!'.format(filePath))

        for elem, elem_data in load_data(filePath).items():
            self.pyControllers[elem] = elem_data["Publish"][:]
            self.pyControllers[elem] += elem_data["NoPublish"]
            for item in elem_data["Publish"]:
                self.publicationList.append(f"{elem} {item}")
예제 #2
0
    def __init__(self, Path):
        self.pyPlots = {}
        filenames = os.listdir(Path)
        found_config_file = False
        found_excel_file = False
        for filename in filenames:
            pyPlotType, ext = os.path.splitext(filename)
            if filename.startswith('~$'):
                continue
            elif ext == '.xlsx':
                filename = convert_config_data_to_toml(filename)
            elif ext != ".toml":
                continue
            if pyPlotType not in self.pyPlots:
                self.pyPlots[pyPlotType] = {}
            filepath = os.path.join(Path, filename)
            assert (os.path.exists(filepath)
                    ), 'path: "{}" does not exist!'.format(filepath)

            assert (os.path.exists(filepath)
                    ), 'path: "{}" does not exist!'.format(filepath)
            for name, plot in load_data(filepath).items():
                if name in self.pyPlots[pyPlotType]:
                    raise InvalidParameter(
                        f"Multiple PyDSS dynamic plot definitions of the same type with the same name not allowed: "
                        f"{name} already exists for plot type {pyPlotType}")
                self.pyPlots[pyPlotType][name] = plot
예제 #3
0
파일: pyContrReader.py 프로젝트: jgu2/PyDSS
 def __init__(self, Path):
     self.pyControllers = {}
     filenames = os.listdir(Path)
     found_config_file = False
     found_excel_file = False
     for filename in filenames:
         pyControllerType, ext = os.path.splitext(filename)
         if filename.startswith('~$'):
             continue
         elif ext == '.xlsx':
             filename = convert_config_data_to_toml(filename)
         elif ext != ".toml":
             continue
         if pyControllerType not in self.pyControllers:
             self.pyControllers[pyControllerType] = {}
         filepath = os.path.join(Path, filename)
         assert (os.path.exists(filepath)
                 ), 'path: "{}" does not exist!'.format(filepath)
         for name, controller in load_data(filepath).items():
             if name in self.pyControllers[pyControllerType]:
                 raise InvalidParameter(
                     f"Multiple PyDSS controller definitions for a single OpenDSS element not allowed: {name}"
                 )
             self.pyControllers[pyControllerType][name] = controller
예제 #4
0
def excel_to_toml(filenames, name=None):
    """Convert an Excel configuration file to TOML."""
    for filename in filenames:
        convert_config_data_to_toml(filename, name)