import hec.heclib 
import hec.io

def locationsAcross(config, dssFilePath):
    records = []
    
    _saveIrregularRecords(records)

def locationsDown(config, dssFilePath):
    records = []
    
    _saveIrregularRecords(records)

def _saveIrregularRecords(records, dssFilePath):
    try:
        dssFile = hec.heclib.dss.HecDss.open(dssFilePath)
        for record in records:
            tsc = _timeSeriesContainer(record)
            dssFile.put(tsc)
    finally:
        dssFile.close()

def _timeSeriesContainer(record):
    """
    record:
      site:
      location:
      parameter:
      version:
      units:
      sampledate:
      samplevalue:
    """
    tsc = hec.io.TimeSeriesContainer()
    
    tsc.watershed = record['site']
    tsc.location = record['location']
    tsc.parameter = record['parameter']
    tsc.version = record['version']
    tsc.fullName = "/%s/%s/%s//IR-YEAR/%s/" % (tsc.watershed, tsc.location, tsc.parameter, tsc.version)
    tsc.interval = -1  # irregular
    tsc.values = [record['samplevalue']]
    tsc.times = [record['sampledate']]
    tsc.startTime = tsc.times[0]
    tsc.endTime = tsc.times[-1]
    tsc.numberValues = 1
    tsc.units = record['units']
    tsc.type = "INST-VAL"
    
    return tsc
@@ -120,26 +120,39 @@
 ords(records
+, dssFilePath
 )%0A
-
 %0Adef locatio
@@ -235,16 +235,29 @@
 (records
+, dssFilePath
 )%0A%0Adef _
@@ -410,22 +410,28 @@
         
-tsc = 
+dssFile.put(
 _timeSer
@@ -454,36 +454,8 @@
 ord)
-%0A            dssFile.put(tsc
 )%0A  

fix `_saveIrregularRecords` calls