Пример #1
0
 def csv(self):
     if self.dataset.geom_type == self.dataset.POINT:
         out = "%.12f,%.12f" % (self.geometry.y, self.geometry.x)
         skip_comma = False
     elif self.dataset.geom_type == self.dataset.PREDEFINED:
         out = ""
         skip_comma = True
     else:
         # Unsupported geometry type?
         out = "ERROR"
         skip_comma = False
     for pd in self.dataset.geopropertydefinition_set.all():
         if skip_comma:
             skip_comma = False
         else:
             out += ","
         try:
             prop = self.geoproperty_set.get(prop=pd)
             out += csv_escape(prop.json_value())
         except GeoProperty.DoesNotExist:
             pass
     out += "\n"
     return out
Пример #2
0
    def csv_header_row(self, use_urls=False):
        """
            Generate (as a string) the header row of a CSV dump of this dataset.  
            Note that prefer_csv() must return True for this to work (i.e. Predefined or Point data)

            If use_urls is True, the headings are property labels (urls). If false they are property names (labels).
        """
        if self.geom_type == self.PREDEFINED:
            out = ""
            skip_comma = True
        else:
            out = "lat,lon"
            skip_comma = False
        for prop in self.geopropertydefinition_set.all():
            if skip_comma:
                skip_comma = False
            else:
                out += ","
            if use_urls:
                out += prop.url
            else:
                out += csv_escape(prop.label)
        out += "\n"
        return out
Пример #3
0
    def csv_header_row(self, use_urls=False):
        """
            Generate (as a string) the header row of a CSV dump of this dataset.  
            Note that prefer_csv() must return True for this to work (i.e. Predefined or Point data)

            If use_urls is True, the headings are property labels (urls). If false they are property names (labels).
        """
        if self.geom_type == self.PREDEFINED:
            out = ""
            skip_comma = True
        else:
            out = "lat,lon"
            skip_comma = False
        for prop in self.properties.all():
            if skip_comma:
                skip_comma = False
            else:
                out += ","
            if use_urls:
                out += prop.url
            else:
                out += csv_escape(prop.label)
        out += "\n"
        return out
Пример #4
0
 def csv(self, view=None):
     """Return a CSV escaped heading for this column"""
     return csv_escape(parametise_label(self.rds.widget, view, self.heading))
Пример #5
0
 def csv(self, view=None):
     """Return a CSV escaped heading for this column"""
     return csv_escape(parametise_label(self.rds.widget, view,
                                        self.heading))
Пример #6
0
 def csv(self):
     return csv_escape(self.value)
Пример #7
0
 def csv(self):
     return csv_escape(self.value)