TNO Intern

Commit 8e9a649c authored by Arjo Segers's avatar Arjo Segers
Browse files

Initialize empty listing with proper columns.

parent f2d41cd0
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@
# 2025-09, Arjo Segers
#   Added "CSO_ColHubMirror_Cleanup" class.
#
# 2026-04, Arjo Segers
#   Initialize columns of listing file.
#

########################################################################
###
@@ -180,8 +183,9 @@ class CSO_ColHubMirror_Inquire(utopya.UtopyaRc):
            # info ..
            logging.info(f"{indent}create %s ..." % lst_file)

            # initiallize for (re)creation:
            listing = cso_file.CSO_Listing()
            # initiallize for (re)creation,
            # define extra columns to ensure correct content even for empty files:
            listing = cso_file.CSO_Listing( columns=["orbit","processing","collection","processor_version","href"] )

            # archive directories
            archive_dirs = self.GetSetting("dir").split()
@@ -282,6 +286,8 @@ class CSO_ColHubMirror_Inquire(utopya.UtopyaRc):

            # endfor # archive_dir

            # info ...
            logging.warning(f"{indent}save ...")
            # sort:
            listing.Sort(by="orbit")
            # save:
+6 −2
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@
#   Updated use of Dataset.dims following deprication warning.
#   Removed whitespace from template replacement.
#
# 2026-04, Arjo Segers
#   Added optional "columns" argument to initialize empty listing object.
#

########################################################################
###
@@ -1306,10 +1309,11 @@ class CSO_Listing(object):
    Optional arguments:

    * ``filename`` : listing file read into table
    * ``columns`` : extra columns that will be created if an empty listing is initialized

    """

    def __init__(self, filename=None, indent=""):
    def __init__(self, filename=None, columns=[], indent=""):
        """
        Initialize empty table or read existing.
        """
@@ -1360,7 +1364,7 @@ class CSO_Listing(object):
            self.dirname = os.curdir

            # new empty table:
            self.df = pandas.DataFrame(columns=["start_time", "end_time"])
            self.df = pandas.DataFrame(columns=["start_time", "end_time"] + columns)

        # endif