

'''Utility functions.'''


import itertools


def ensure_list(string_or_list_or_none, separator=None):
    if isinstance(string_or_list_or_none, str):
        if separator:
            return string_or_list_or_none.split(separator)
        else:
            return [string_or_list_or_none]
    else:
        if separator:
            return list(itertools.chain.from_iterable(
                item.split(separator) for item in string_or_list_or_none))
        else:
            return string_or_list_or_none or []



'''Utility functions.'''


import itertools


def ensure_list(string_or_list_or_none, separator=None):
    if isinstance(string_or_list_or_none, str):
        if separator:
            return string_or_list_or_none.split(separator)
        else:
            return [string_or_list_or_none]
    elif string_or_list_or_none is not None:
        if separator:
            return list(itertools.chain.from_iterable(
                item.split(separator) for item in string_or_list_or_none))
        else:
            return string_or_list_or_none
    else:
        return []

Fix crash when no commandline args are passed
Fix crash when no commandline args are passed

Regression from 3513da19363b8b4564f199b469d13486996ede57

  
  
  '''Utility functions.'''
  
  
  import itertools
  
  
  def ensure_list(string_or_list_or_none, separator=None):
      if isinstance(string_or_list_or_none, str):
          if separator:
              return string_or_list_or_none.split(separator)
          else:
              return [string_or_list_or_none]
-     else:
+     elif string_or_list_or_none is not None:
          if separator:
              return list(itertools.chain.from_iterable(
                  item.split(separator) for item in string_or_list_or_none))
          else:
-             return string_or_list_or_none or []
+             return string_or_list_or_none
+     else:
+         return []
  
Fix crash when no commandline args are passed
## Code Before:


'''Utility functions.'''


import itertools


def ensure_list(string_or_list_or_none, separator=None):
    if isinstance(string_or_list_or_none, str):
        if separator:
            return string_or_list_or_none.split(separator)
        else:
            return [string_or_list_or_none]
    else:
        if separator:
            return list(itertools.chain.from_iterable(
                item.split(separator) for item in string_or_list_or_none))
        else:
            return string_or_list_or_none or []

## Instruction:
Fix crash when no commandline args are passed
## Code After:


'''Utility functions.'''


import itertools


def ensure_list(string_or_list_or_none, separator=None):
    if isinstance(string_or_list_or_none, str):
        if separator:
            return string_or_list_or_none.split(separator)
        else:
            return [string_or_list_or_none]
    elif string_or_list_or_none is not None:
        if separator:
            return list(itertools.chain.from_iterable(
                item.split(separator) for item in string_or_list_or_none))
        else:
            return string_or_list_or_none
    else:
        return []
