[GRASS-SVN] r73063 - grass-addons/grass7/raster/r.in.pdal

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 8 18:12:47 PDT 2018


Author: wenzeslaus
Date: 2018-08-08 18:12:47 -0700 (Wed, 08 Aug 2018)
New Revision: 73063

Modified:
   grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py
Log:
r.in.pdal: greater PEP8 compliance using pylint

Fixing bad-continuation (wrong hanging indentation) and wrong-import-order.
Following pep8 tool (and PEP8), not pylint, on indent of closing parenthesis.


Modified: grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py
===================================================================
--- grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py	2018-08-08 06:59:33 UTC (rev 73062)
+++ grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py	2018-08-09 01:12:47 UTC (rev 73063)
@@ -141,12 +141,13 @@
 
 import os
 import sys
+import json
+import gettext
 
 import grass.script as grass
-import json
 
+
 # i18N
-import gettext
 gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'))
 
 
@@ -160,7 +161,7 @@
     """
     if not grass.find_program('pdal', 'info --boundary'):
         grass.fatal(_(
-             "pdal info --boundary is not in the path and executable"))
+            "pdal info --boundary is not in the path and executable"))
     command_fp = ['pdal', 'info', '--boundary', infile]
     tmp_fp = grass.tempfile()
     if tmp_fp is None:
@@ -195,58 +196,51 @@
     f = open(tmp_xy, 'w')
     f.write(xy_in[:-1])
     f.close()
-    grass.run_command(
-                        'v.in.lines',
-                        input=tmp_xy,
-                        output='footprint_line',
-                        separator='comma'
+    grass.run_command('v.in.lines',
+                      input=tmp_xy,
+                      output='footprint_line',
+                      separator='comma'
                       )
     grass.run_command('g.region', vector='footprint_line')
-    grass.run_command(
-                        'v.type',
-                        input='footprint_line',
-                        out='footprint_boundary',
-                        from_type='line',
-                        to_type='boundary'
-                    )
+    grass.run_command('v.type',
+                      input='footprint_line',
+                      out='footprint_boundary',
+                      from_type='line',
+                      to_type='boundary'
+                      )
     grass.run_command('v.centroids', input='footprint_boundary', out=footprint)
-    grass.run_command(
-                        'v.db.addtable',
-                        map=footprint,
-                        columns='name varchar(50)'
-                    )
-    grass.run_command(
-                        'v.db.update',
-                        map=footprint,
-                        column='name',
-                        value=infile
-                    )
+    grass.run_command('v.db.addtable',
+                      map=footprint,
+                      columns='name varchar(50)'
+                      )
+    grass.run_command('v.db.update',
+                      map=footprint,
+                      column='name',
+                      value=infile
+                      )
 
     # Cleaning up
     grass.message(_("Cleaning up..."))
     os.remove(tmp_fp)
     os.remove(tmp_xy)
-    grass.run_command(
-                        'g.remove',
-                        flags='f',
-                        type='vector',
-                        name='footprint_line',
-                        quiet=True
-                    )
-    grass.run_command(
-                        'g.remove',
-                        flags='f',
-                        type='vector',
-                        name='footprint_boundary',
-                        quiet=True
-                    )
+    grass.run_command('g.remove',
+                      flags='f',
+                      type='vector',
+                      name='footprint_line',
+                      quiet=True
+                      )
+    grass.run_command('g.remove',
+                      flags='f',
+                      type='vector',
+                      name='footprint_boundary',
+                      quiet=True
+                      )
 
     # metadata
-    grass.run_command(
-                        'v.support',
-                        map=footprint,
-                        comment='in ' + os.environ['CMDLINE']
-                    )
+    grass.run_command('v.support',
+                      map=footprint,
+                      comment='in ' + os.environ['CMDLINE']
+                      )
 
     grass.message(_("Generating output vector map <%s>...") % footprint)
 
@@ -307,8 +301,7 @@
             os.remove(tmp_scan)
             grass.fatal(_(
                 "pdal cannot determine metadata " +
-                "for unsupported format of <%s>")
-                % infile)
+                "for unsupported format of <%s>") % infile)
         data = json.load(open(tmp_scan))
         if summary:
             str1 = u'summary'
@@ -338,12 +331,10 @@
         if not shell_script_style:
             grass.message(_(
                 "north: %s\nsouth: %s\nwest: %s\neast: %s\ntop: %s\nbottom: %s"
-            )
-                % (n, s, w, e, t, b))
+                ) % (n, s, w, e, t, b))
         else:
-            grass.message(_(
-                "n=%s s=%s w=%s e=%s t=%s b=%s")
-                % (n, s, w, e, t, b))
+            grass.message(_("n=%s s=%s w=%s e=%s t=%s b=%s")
+                          % (n, s, w, e, t, b))
     elif footprint:
         footprint_to_vectormap(infile, footprint)
     else:
@@ -352,12 +343,11 @@
 
         if raster_file:
             raster_reference = 'img'
-            grass.run_command(
-                                'r.external',
-                                input=raster_file,
-                                flags='o',
-                                output=raster_reference
-                            )
+            grass.run_command('r.external',
+                              input=raster_file,
+                              flags='o',
+                              output=raster_reference
+                              )
             result = grass.find_file(name=raster_reference, element='raster')
             if result[u'fullname'] == u'':
                 raster_reference = 'img.1'
@@ -365,20 +355,18 @@
         # geometry to raster_reference
         grass.run_command('g.region', vector='tiles', flags='p')
         if raster_reference:
-            grass.run_command(
-                                'g.region',
-                                vector='tiles',
-                                flags='ap',
-                                align=raster_reference
-                            )
+            grass.run_command('g.region',
+                              vector='tiles',
+                              flags='ap',
+                              align=raster_reference
+                              )
         # second pass: change raster resolution to final resolution while best
         # effort aligning to pixel geometry
-        grass.run_command(
-                            'g.region',
-                            vector='tiles',
-                            flags='ap',
-                            res=resolution
-                        )
+        grass.run_command('g.region',
+                          vector='tiles',
+                          flags='ap',
+                          res=resolution
+                          )
 
         # . pdal pipline laz2json (STDOUT) | r.in.xyz
         bn = os.path.basename(infile)
@@ -391,13 +379,12 @@
         elif infile_format.lower() == 'pts':
             format_reader = 'readers.pts'
         else:
-            grass.run_command(
-                                'g.remove',
-                                flags='f',
-                                type='vector',
-                                name='tiles',
-                                quiet=True
-                            )
+            grass.run_command('g.remove',
+                              flags='f',
+                              type='vector',
+                              name='tiles',
+                              quiet=True
+                              )
             grass.fatal(_("Format .%s is not supported.." % infile_format))
         tmp_file_json = grass.tempfile()
         if tmp_file_json is None:
@@ -455,29 +442,26 @@
             grass.fatal("Unable to create temporary files")
         f = file(empty_histroy, 'w')
         f.close()
-        grass.run_command(
-                            'r.support',
-                            map=outfile,
-                            source1=infile,
-                            description='generated by r.in.pdal',
-                            loadhistory=empty_histroy
-                        )
-        grass.run_command(
-                            'r.support',
-                            map=outfile,
-                            history=os.environ['CMDLINE']
-                        )
+        grass.run_command('r.support',
+                          map=outfile,
+                          source1=infile,
+                          description='generated by r.in.pdal',
+                          loadhistory=empty_histroy
+                          )
+        grass.run_command('r.support',
+                          map=outfile,
+                          history=os.environ['CMDLINE']
+                          )
         os.remove(empty_histroy)
 
         # Cleanup
         grass.message(_("Cleaning up..."))
-        grass.run_command(
-                            'g.remove',
-                            flags='f',
-                            type='vector',
-                            name='tiles',
-                            quiet=True
-                        )
+        grass.run_command('g.remove',
+                          flags='f',
+                          type='vector',
+                          name='tiles',
+                          quiet=True
+                          )
         os.remove(tmp_file_json)
         os.remove(tmp_xyz)
         grass.message(_("Generating output raster map <%s>...") % outfile)



More information about the grass-commit mailing list