old_contents: import os
  import json
  
  
  def load_countries():
      helpers_path = os.path.abspath(os.path.dirname(__file__))
      countryfile = os.path.join(helpers_path, '../../static/location-autocomplete-canonical-list.json')
      with open(countryfile) as f:
          return json.load(f)
  
  
  def get_country_name_from_country_code(country_code):
      if country_code and country_code == 'gb':
          # We need to support the old country code style ('gb') until after the existing country code data we have in the
          # database has been updated by a script we'll run.
          # TODO: Remove support for old country codes after migration.
          return 'United Kingdom'
      elif country_code:
          for country in COUNTRY_TUPLE:
              if country[1] == country_code:
                  return country[0]
          return ''
      else:
          # In the case that a suppliers registration country isn't set we maintain existing behavior, which is for the
          # country to be returned as an empty string. 15/02/18
          return ''
  
  
  COUNTRY_TUPLE = load_countries()
  
  
  def supplier_company_details_are_complete(supplier_data):
      supplier_required_fields = ['dunsNumber', 'name', 'registeredName', 'registrationCountry', 'organisationSize',
                                  'tradingStatus']
      contact_required_fields = ['address1', 'city', 'postcode']
  
      registration_country = supplier_data['registrationCountry'] if 'registrationCountry' in supplier_data else None
      if registration_country == 'gb' or registration_country == 'country:GB':
          supplier_required_fields.append('companiesHouseNumber')
          supplier_required_fields.append('vatNumber')
  
      else:
          supplier_required_fields.append('otherCompanyRegistrationNumber')
  
      return (
          all([f in supplier_data and supplier_data[f] for f in supplier_required_fields]) and
          all([f in supplier_data['contactInformation'][0] and supplier_data['contactInformation'][0][f]
               for f in
               contact_required_fields])
      )
  
  
  def parse_form_errors_for_validation_masthead(forms):
      form_list = forms if isinstance(forms, (list, tuple)) else [forms]
  
      errors = []
      for form in form_list:
          errors += [{
              'question': form[field].label.text,
              'input_name': form[field].name,
          } for field in form.errors.keys()]
  
      return errors
  
new_contents: import os
  import json
  
  
  def load_countries():
      helpers_path = os.path.abspath(os.path.dirname(__file__))
      countryfile = os.path.join(helpers_path, '../../static/location-autocomplete-canonical-list.json')
      with open(countryfile) as f:
          return json.load(f)
  
  
  def get_country_name_from_country_code(country_code):
      if country_code and country_code == 'gb':
          # We need to support the old country code style ('gb') until after the existing country code data we have in the
          # database has been updated by a script we'll run.
          # TODO: Remove support for old country codes after migration.
          return 'United Kingdom'
      elif country_code:
          for country in COUNTRY_TUPLE:
              if country[1] == country_code:
                  return country[0]
          return ''
      else:
          # In the case that a suppliers registration country isn't set we maintain existing behavior, which is for the
          # country to be returned as an empty string. 15/02/18
          return ''
  
  
  COUNTRY_TUPLE = load_countries()
  
  
  def supplier_company_details_are_complete(supplier_data):
      supplier_required_fields = ['dunsNumber', 'name', 'registeredName', 'registrationCountry', 'organisationSize',
                                  'tradingStatus', 'vatNumber']
      contact_required_fields = ['address1', 'city', 'postcode']
  
      # We require one of either 'companiesHouseNumber' or 'otherCompanyRegistrationNumber'
      if 'companiesHouseNumber' in supplier_data:
          supplier_required_fields.append('companiesHouseNumber')
      else:
          supplier_required_fields.append('otherCompanyRegistrationNumber')
  
      return (
          all([f in supplier_data and supplier_data[f] for f in supplier_required_fields]) and
          all([f in supplier_data['contactInformation'][0] and supplier_data['contactInformation'][0][f]
               for f in
               contact_required_fields])
      )
  
  
  def parse_form_errors_for_validation_masthead(forms):
      form_list = forms if isinstance(forms, (list, tuple)) else [forms]
  
      errors = []
      for form in form_list:
          errors += [{
              'question': form[field].label.text,
              'input_name': form[field].name,
          } for field in form.errors.keys()]
  
      return errors
  
subject: Update logic of supplier_company_details_are_complete