Example #1
0
    def test_justify_row_without_words(self):
        row = 'a' * 400
        ret = justify_row(row)
        self.assertEqual(ret, ['    ' + row])

        row = 'b' * 5
        ret = justify_row(row)
        self.assertEqual(ret, ['    ' + row])
Example #2
0
    def test_justify_row_without_words(self):
        row = "a" * 400
        ret = justify_row(row)
        self.assertEqual(ret, ["    " + row])

        row = "b" * 5
        ret = justify_row(row)
        self.assertEqual(ret, ["    " + row])
Example #3
0
    def test_justify_row_without_words(self):
        row = 'a' * 400
        ret = justify_row(row)
        self.assertEqual(ret, ['    ' + row])

        row = 'b' * 5
        ret = justify_row(row)
        self.assertEqual(ret, ['    ' + row])
Example #4
0
    def get_rows(self):
        lines = ['OpenClimateGIS v{0} Metadata File'.format(ocgis.__RELEASE__)]
        lines.append('  Generated (UTC): {0}'.format(
            datetime.datetime.utcnow()))
        lines.append('')
        lines.append('== Potential Header Names with Definitions ==')
        lines.append('')
        sh = sorted(HEADERS)
        for key in sh:
            msg = '  {0} :: {1}'.format(key.upper(), '\n'.join(
                justify_row(HEADERS[key]))).replace('::     ', ':: ')
            lines.append(msg)
        lines.append('')
        lines.append('== Argument Definitions and Content Descriptions ==')
        lines.append('')
        for k, v in sorted(self.ops.__dict__.iteritems()):
            if isinstance(v, OcgParameter):
                lines.append(v.get_meta())

        ## append the url representation of the data request
        lines.append('== URL Representation ==')
        lines.append('')
        lines.append(self.ops.as_url())

        ## collapse lists
        ret = []
        for line in lines:
            if not isinstance(line, basestring):
                for item in line:
                    ret.append(item)
            else:
                ret.append(line)
        return (ret)
Example #5
0
 def get_rows(self):
     lines = ['OpenClimateGIS v{0} Metadata File'.format(ocgis.__RELEASE__)]
     lines.append('  Generated (UTC): {0}'.format(datetime.datetime.utcnow()))
     lines.append('')
     lines.append('== Potential Header Names with Definitions ==')
     lines.append('')
     sh = sorted(HEADERS)
     for key in sh:
         msg = '  {0} :: {1}'.format(key.upper(),'\n'.join(justify_row(HEADERS[key]))).replace('::     ',':: ')
         lines.append(msg)
     lines.append('')
     lines.append('== Argument Definitions and Content Descriptions ==')
     lines.append('')
     for k,v in sorted(self.ops.__dict__.iteritems()):
         if isinstance(v,OcgParameter):
             lines.append(v.get_meta())
     
     ## append the url representation of the data request
     lines.append('== URL Representation ==')
     lines.append('')
     lines.append(self.ops.as_url())
         
     ## collapse lists
     ret = []
     for line in lines:
         if not isinstance(line,basestring):
             for item in line:
                 ret.append(item)
         else:
             ret.append(line)
     return(ret)
Example #6
0
File: meta.py Project: NCPP/ocgis
    def get_rows(self):
        lines = ['OpenClimateGIS v{0} Metadata File'.format(ocgis.__release__)]
        lines.append('  Generated (UTC): {0}'.format(datetime.datetime.utcnow()))
        lines.append('')
        if self.ops.output_format != 'meta':
            lines.append(
                'This is OpenClimateGIS-related metadata. Data-level metadata may be found in the file named: {0}'.format(
                    self.ops.prefix + '_source_metadata.txt'))
            lines.append('')
        lines.append('== Potential Header Names with Definitions ==')
        lines.append('')
        sh = sorted(HEADERS)
        for key in sh:
            msg = '  {0} :: {1}'.format(key.upper(), '\n'.join(justify_row(HEADERS[key]))).replace('::     ', ':: ')
            lines.append(msg)
        lines.append('')
        lines.append('== Argument Definitions and Content Descriptions ==')
        lines.append('')

        sorted_keys = sorted(self.ops.__dict__)
        for key in sorted_keys:
            curr = self.ops.__dict__[key]
            if isinstance(curr, AbstractParameter):
                lines.append(curr.get_meta())

        # collapse lists
        ret = []
        for line in lines:
            if not isinstance(line, six.string_types):
                for item in line:
                    ret.append(item)
            else:
                ret.append(line)
        return ret
Example #7
0
File: meta.py Project: imclab/ocgis
    def get_rows(self):
        lines = ['OpenClimateGIS v{0} Metadata File'.format(ocgis.__RELEASE__)]
        lines.append('  Generated (UTC): {0}'.format(
            datetime.datetime.utcnow()))
        lines.append('')
        if self.ops.output_format != 'meta':
            lines.append(
                'This is OpenClimateGIS-related metadata. Data-level metadata may be found in the file named: {0}'
                .format(self.ops.prefix + '_source_metadata.txt'))
            lines.append('')
        lines.append('== Potential Header Names with Definitions ==')
        lines.append('')
        sh = sorted(HEADERS)
        for key in sh:
            msg = '  {0} :: {1}'.format(key.upper(), '\n'.join(
                justify_row(HEADERS[key]))).replace('::     ', ':: ')
            lines.append(msg)
        lines.append('')
        lines.append('== Argument Definitions and Content Descriptions ==')
        lines.append('')
        for v in sorted(self.ops.__dict__.itervalues()):
            if isinstance(v, OcgParameter):
                lines.append(v.get_meta())

        ## collapse lists
        ret = []
        for line in lines:
            if not isinstance(line, basestring):
                for item in line:
                    ret.append(item)
            else:
                ret.append(line)
        return (ret)
Example #8
0
 def test_justify_long_word(self):
     aes = 'a' * 400
     row = ' '.join(['short', aes, 'end'])
     ret = justify_row(row)
     self.assertEqual(ret, [
         '    short aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa end'
     ])
Example #9
0
 def test_justify_row(self):
     row = "Food is any substance[1] consumed to provide nutritional support for the body. It is usually of plant or animal origin, and contains essential nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals. The substance is ingested by an organism and assimilated by the organism's cells in an effort to produce energy, maintain life, or stimulate growth."
     eq = ['    Food is any substance[1] consumed to provide nutritional support for the',
           '    body. It is usually of plant or animal origin, and contains essential',
           '    nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals.',
           "    The substance is ingested by an organism and assimilated by the organism's",
           '    cells in an effort to produce energy, maintain life, or stimulate growth.']
     justified = justify_row(row)
     self.assertEqual(justified, eq)
Example #10
0
 def test_justify_long_word(self):
     aes = "a" * 400
     row = " ".join(["short", aes, "end"])
     ret = justify_row(row)
     self.assertEqual(
         ret,
         [
             "    short aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa end"
         ],
     )
Example #11
0
 def get_meta(self):
     ''':rtype: list of strings'''
     subrows = self._get_meta_()
     if isinstance(subrows, basestring):
         subrows = [subrows]
     rows = [self.__repr__()]
     for row in subrows:
         rows.extend(justify_row(row))
         rows.append('')
     return (rows)
Example #12
0
 def get_meta(self):
     ''':rtype: list of strings'''
     subrows = self._get_meta_()
     if isinstance(subrows,basestring):
         subrows = [subrows]
     rows = [self.__repr__()]
     for row in subrows:
         rows.extend(justify_row(row))
         rows.append('')
     return(rows)
Example #13
0
 def test_justify_row(self):
     row = "Food is any substance[1] consumed to provide nutritional support for the body. It is usually of plant or animal origin, and contains essential nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals. The substance is ingested by an organism and assimilated by the organism's cells in an effort to produce energy, maintain life, or stimulate growth."
     eq = [
         '    Food is any substance[1] consumed to provide nutritional support for the',
         '    body. It is usually of plant or animal origin, and contains essential',
         '    nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals.',
         "    The substance is ingested by an organism and assimilated by the organism's",
         '    cells in an effort to produce energy, maintain life, or stimulate growth.'
     ]
     justified = justify_row(row)
     self.assertEqual(justified, eq)
Example #14
0
 def test_justify_long_word(self):
     aes = 'a' * 400
     row = ' '.join(['short', aes, 'end'])
     ret = justify_row(row)
     self.assertEqual(ret, [
         '    short aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa end'])