示例#1
0
文件: cli.py 项目: agravier/csvtopg
def load_toml_file(conf_file: _io.TextIOWrapper) -> Dict:
    """Create a dictionary from the configuration specified in the loaded TOML
    configuration file. Note that no Config object is created, just a dict.

    :param conf_file: file data as TextIOWrapper
    :return: hierarchical configuration in a dictionary
    """
    try:
        return toml.load(conf_file)
    finally:
        conf_file.close()
    def finalize_results_logging(self, csvf: _io.TextIOWrapper, loss: float,
                                 f1: float):
        """
        Finalize writing of result CSV
        :param csvf: CSV file handle
        :param loss: loss reached with result
        :param f1: F1 reached with result
        """

        csvf.close()
        os.rename(
            self.TMP_FNAME,
            f"introspection/introspection"
            f"_{str(self.__class__)}_A{f1:.6f}_L{loss:.6f}_{socket.gethostname()}.tsv",
        )
示例#3
0
def cleanData_CB__closeFiles(hFileRead: _io.TextIOWrapper,
                             hFileWrite: _io.TextIOWrapper):
    # Generic function to close files associated with CrunchBase cleaning routine
    hFileRead.close()
    hFileWrite.close()
    return
示例#4
0
def main(name: str, fin: _io.TextIOWrapper) -> tuple:
    if len(fin.read(CHUNK)) == CHUNK:
        fin.close()
        name = f'{name}{datetime.now()}'
        fin = open(name, 'w')
    return name, fin
示例#5
0
def _closeFile(f: _io.TextIOWrapper) -> None:
    f.close()