[hdf-compass] 179/295: Improve the asc_model can_handle method by reading the first file line

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit 5655841af58e472b2538e3b8878776406317df19
Author: giumas <giumas at yahoo.it>
Date:   Thu Oct 22 20:38:26 2015 -0400

    Improve the asc_model can_handle method by reading the first file line
---
 hdf_compass/asc_model/model.py        | 6 ++++++
 hdf_compass/compass_model/__init__.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hdf_compass/asc_model/model.py b/hdf_compass/asc_model/model.py
index cfcf5cb..67ec3d9 100644
--- a/hdf_compass/asc_model/model.py
+++ b/hdf_compass/asc_model/model.py
@@ -65,6 +65,12 @@ class AsciiGrid(compass_model.Store):
         if not url.endswith('.asc'):
             log.debug("able to handle %s? no, missing .asc extension" % url)
             return False
+
+        first_line = open(url2path(url)).readline()
+        if first_line.split()[0].upper() != "NCOLS":
+            log.debug("able to handle %s? no, invalid first line" % url)
+            return False
+
         log.debug("able to handle %s? yes" % url)
         return True
 
diff --git a/hdf_compass/compass_model/__init__.py b/hdf_compass/compass_model/__init__.py
index 4a335ab..0853f0a 100644
--- a/hdf_compass/compass_model/__init__.py
+++ b/hdf_compass/compass_model/__init__.py
@@ -11,7 +11,7 @@
 ##############################################################################
 from __future__ import absolute_import, division, print_function, unicode_literals
 
-from .model import get_stores, push, Store, Node, Container, KeyValue, Array, Text, Xml, Image, Plottable, Unknown
+from .model import get_stores, push, Store, Node, Container, KeyValue, Array, Text, Xml, Image, Unknown
 
 import logging
 log = logging.getLogger(__name__)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list