[GRASS-SVN] r65967 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 18 08:51:08 PDT 2015
Author: huhabla
Date: 2015-08-18 08:51:08 -0700 (Tue, 18 Aug 2015)
New Revision: 65967
Modified:
grass/trunk/lib/python/temporal/stds_import.py
Log:
temporal library: Fixed import of STRDS generated from R
Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py 2015-08-18 15:18:32 UTC (rev 65966)
+++ grass/trunk/lib/python/temporal/stds_import.py 2015-08-18 15:51:08 UTC (rev 65967)
@@ -211,12 +211,14 @@
# Check for important files
members = tar.getnames()
+ # Make sure that the basenames of the files are used for comparison
+ member_basenames = [os.path.basename(name) for name in members]
- if init_file_name not in members:
+ if init_file_name not in member_basenames:
gscript.fatal(_("Unable to find init file <%s>") % init_file_name)
- if list_file_name not in members:
+ if list_file_name not in member_basenames:
gscript.fatal(_("Unable to find list file <%s>") % list_file_name)
- if proj_file_name not in members:
+ if proj_file_name not in member_basenames:
gscript.fatal(_("Unable to find projection file <%s>") % proj_file_name)
tar.extractall(path=directory)
@@ -236,11 +238,26 @@
temp_file = open(temp_name, "w")
proj_name = os.path.abspath(proj_file_name)
+ # We need to convert projection strings generated
+ # from other programms than g.proj into
+ # new line format so that the grass file comparison function
+ # can be used to compare the projections
+ proj_name_tmp = temp_name + "_in_projection"
+ proj_file = open(proj_name, "r")
+ proj_content = proj_file.read()
+ proj_content = proj_content.replace(" +", "\n+")
+ proj_content = proj_content.replace("\t+", "\n+")
+ proj_file.close()
+
+ proj_file = open(proj_name_tmp, "w")
+ proj_file.write(proj_content)
+ proj_file.close()
+
p = gscript.start_command("g.proj", flags="j", stdout=temp_file)
p.communicate()
temp_file.close()
- if not gscript.compare_key_value_text_files(temp_name, proj_name,
+ if not gscript.compare_key_value_text_files(temp_name, proj_name_tmp,
sep="="):
if overr:
gscript.warning(_("Projection information does not match. "
More information about the grass-commit
mailing list