parameters: (properties_filename)
return_statement: return PortalProperties(properties[DATABASE_HOST],
                              properties[DATABASE_NAME],
                              properties[DATABASE_USER],
                              properties[DATABASE_PW],
                              properties[DATABASE_USE_SSL])
docstring: Returns a properties object
docstring_summary: Returns a properties object
docstring_tokens: Returns a properties object
function: def get_portal_properties(properties_filename):
      """ Returns a properties object """
      properties = {}
      with open(properties_filename, 'r') as properties_file:
          for line in properties_file:
              line = line.strip()
              # skip line if its blank or a comment
              if len(line) == 0 or line.startswith('#'):
                  continue
              try:
                  name, value = line.split('=', maxsplit=1)
              except ValueError:
                  print(
                      'Skipping invalid entry in property file: %s' % (line),
                      file=ERROR_FILE)
                  continue
              properties[name] = value.strip()
      missing_properties = []
      for required_property in REQUIRED_PROPERTIES:
          if required_property not in properties or len(properties[required_property]) == 0:
              missing_properties.append(required_property)
      if missing_properties:
          print(
              'Missing required properties : (%s)' % (', '.join(missing_properties)),
              file=ERROR_FILE)
          return None
      # return an instance of PortalProperties
      return PortalProperties(properties[DATABASE_HOST],
                              properties[DATABASE_NAME],
                              properties[DATABASE_USER],
                              properties[DATABASE_PW],
                              properties[DATABASE_USE_SSL])
function_tokens: def get_portal_properties ( properties_filename ) : properties = { } with open ( properties_filename , 'r' ) as properties_file : for line in properties_file : line = line . strip ( ) # skip line if its blank or a comment if len ( line ) == 0 or line . startswith ( '#' ) : continue try : name , value = line . split ( '=' , maxsplit = 1 ) except ValueError : print ( 'Skipping invalid entry in property file: %s' % ( line ) , file = ERROR_FILE ) continue properties [ name ] = value . strip ( ) missing_properties = [ ] for required_property in REQUIRED_PROPERTIES : if required_property not in properties or len ( properties [ required_property ] ) == 0 : missing_properties . append ( required_property ) if missing_properties : print ( 'Missing required properties : (%s)' % ( ', ' . join ( missing_properties ) ) , file = ERROR_FILE ) return None # return an instance of PortalProperties return PortalProperties ( properties [ DATABASE_HOST ] , properties [ DATABASE_NAME ] , properties [ DATABASE_USER ] , properties [ DATABASE_PW ] , properties [ DATABASE_USE_SSL ] )