예제 #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])
예제 #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])
예제 #3
0
파일: test_justify.py 프로젝트: NCPP/ocgis
    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])
예제 #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)
예제 #5
0
파일: meta.py 프로젝트: aashish24/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('')
     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)
예제 #6
0
파일: meta.py 프로젝트: 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
예제 #7
0
파일: meta.py 프로젝트: 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)
예제 #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'
     ])
예제 #9
0
파일: test_justify.py 프로젝트: NCPP/ocgis
 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)
예제 #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"
         ],
     )
예제 #11
0
파일: base.py 프로젝트: aashish24/ocgis
 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)
예제 #12
0
파일: base.py 프로젝트: aashish24/ocgis
 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)
예제 #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)
예제 #14
0
파일: test_justify.py 프로젝트: NCPP/ocgis
 def test_justify_long_word(self):
     aes = 'a' * 400
     row = ' '.join(['short', aes, 'end'])
     ret = justify_row(row)
     self.assertEqual(ret, [
         '    short aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa end'])