Skip to content

Commit

Permalink
Fix an issue with the info command on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanwp committed Mar 31, 2017
1 parent dd092d6 commit 5e79559
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
ungridded, but not a mix. For ungridded data lists it is assumed that all objects share the same coordinates.
"""
__author__ = "David Michel, Daniel Wallis, Duncan Watson-Parris, Richard Wilkinson, Ian Bush, Matt Kendall, John Holt"
__version__ = "1.5.3"
__status__ = "Stable"
__version__ = "1.5.4"
__status__ = "Dev"
__website__ = "http://www.cistools.net/"

__all__ = ['read_data', 'read_data_list', 'get_variables']
Expand Down
2 changes: 1 addition & 1 deletion cis/cis_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def info_cmd(main_arguments):
"""
from cis.info import info
dg = main_arguments.datagroups[0]
info(dg['filenames'], dg['variables'], dg.get('product', None), main_arguments.type)
info(dg['filenames'], dg.get('variables', None), dg.get('product', None), main_arguments.type)


def col_cmd(main_arguments):
Expand Down
12 changes: 8 additions & 4 deletions cis/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,17 @@ def validate_plot_args(arguments, parser):


def validate_info_args(arguments, parser):
from collections import namedtuple
# See how many colon-split arguments there are (taking into account escaped colons)
split_input = [re.sub(r'([\\]):', r':', word) for word in re.split(r'(?<!\\):', arguments.datagroups[0])]
if len(split_input) == 1:
# If there is only one part of the datagroup then it must be a file (or list of files). Return it as a dict to
# match the behaviour of the datagroup parser.
arguments.datagroups = [{'filenames': expand_file_list(arguments.datagroups[0], parser),
'variables': None, 'product': None}]
# If there is only one part of the datagroup then it must be a file (or list of files).
DatagroupOptions = namedtuple('DatagroupOptions', ["filenames"])
datagroup_options = DatagroupOptions(expand_file_list)
arguments.datagroups = parse_colon_and_comma_separated_arguments(arguments.datagroups, parser,
datagroup_options, compulsory_args=1)
else:
# Otherwise it's a standard datagroup
arguments.datagroups = get_basic_datagroups(arguments.datagroups, parser)
return arguments

Expand Down
Binary file added cis/test/integration/collocated_gassp.nc
Binary file not shown.
Binary file added cis/test/integration/tmp_file.nc
Binary file not shown.
10 changes: 5 additions & 5 deletions cis/test/unit/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def test_GIVEN_info_command_WHEN_single_file_present_THEN_empty_variable_and_pro
assert_that(len(dg), is_(1))
assert_that(dg[0]['filenames'], is_([self.test_directory_files[0]]))
assert_that(dg[0].get('product', None), is_(None))
assert_that(dg[0]['variables'], is_(None))
assert_that(dg[0].get('variables', None), is_(None))

def test_GIVEN_info_command_WHEN_many_files_present_THEN_empty_variable_and_product(self):
args = ["info", ",".join(self.escaped_test_directory_files)]
Expand All @@ -742,7 +742,7 @@ def test_GIVEN_info_command_WHEN_many_files_present_THEN_empty_variable_and_prod
assert_that(len(dg), is_(1))
assert_that(dg[0]['filenames'], is_(self.test_directory_files))
assert_that(dg[0].get('product', None), is_(None))
assert_that(dg[0]['variables'], is_(None))
assert_that(dg[0].get('variables', None), is_(None))

def test_GIVEN_info_command_WHEN_files_and_single_var_present_THEN_single_variable_and_empty_product(self):
var1 = 'rain'
Expand All @@ -752,7 +752,7 @@ def test_GIVEN_info_command_WHEN_files_and_single_var_present_THEN_single_variab
assert_that(len(dg), is_(1))
assert_that(dg[0]['filenames'], is_([self.test_directory_files[0]]))
assert_that(dg[0].get('product', None), is_(None))
assert_that(dg[0]['variables'], is_([var1]))
assert_that(dg[0].get('variables', None), is_([var1]))

def test_GIVEN_info_command_WHEN_files_and_many_vars_present_THEN_many_variable_and_empty_product(self):
var1, var2 = 'rain', 'snow'
Expand All @@ -762,7 +762,7 @@ def test_GIVEN_info_command_WHEN_files_and_many_vars_present_THEN_many_variable_
assert_that(len(dg), is_(1))
assert_that(dg[0]['filenames'], is_([self.test_directory_files[0]]))
assert_that(dg[0].get('product', None), is_(None))
assert_that(dg[0]['variables'], contains_inanyorder('rain', 'snow'))
assert_that(dg[0].get('variables', None), contains_inanyorder('rain', 'snow'))

def test_GIVEN_info_command_WHEN_files_and_var_and_product_present_THEN_variable_and_product_set(self):
var1 = 'rain'
Expand All @@ -773,4 +773,4 @@ def test_GIVEN_info_command_WHEN_files_and_var_and_product_present_THEN_variable
assert_that(len(dg), is_(1))
assert_that(dg[0]['filenames'], is_([self.test_directory_files[0]]))
assert_that(dg[0].get('product', None), is_('cis'))
assert_that(dg[0]['variables'], is_([var1]))
assert_that(dg[0].get('variables', None), is_([var1]))

0 comments on commit 5e79559

Please sign in to comment.