Ejemplo n.º 1
0
 def _yaml_include(loader, node):
     filename = self._locate(node.value)
     if not filename:
         msg = "Failed to locate included file '{}'".format(node.value)
         self.errs.append(msg)
         return None
     file_dict[filename] = 1
     with utils.open_file(filename) as inputfile:
         return yaml.load(inputfile, Loader)
Ejemplo n.º 2
0
    def read_report_csv(filepath, rmindex=True):
        rows = []
        try:
            with utils.open_file(filepath) as fd:
                for row in csv.reader(fd):
                    if row[0] != '#':
                        if rmindex:
                            row.pop(0)
                        rows.append(row)
        except Exception:
            #print("failed to open {} to read".format(filepath))
            pass

        return rows
Ejemplo n.º 3
0
 def init_file(self, filename, paths=[]):
     self._init_paths(filename, paths)
     file_path = self._locate(filename)
     if not file_path:
         self.errs.append("File {} not found".format(filename))
         return None
     fh = utils.open_file(file_path)
     if not fh:
         self.errs.append("Failed to open {}".format(filename))
         return None
     try:
         text0 = fh.read()
         fh.close()
         self.all_files = self.init_content(text0)
         self.all_files[file_path] = 1
         return file_path
     except Exception as e:
         self.errs.append(e)
         raise (e)