def get_words(file_path=None, content=None, extension=None):
 if (((file_path is None) and ((content is None) or (extension is None))) or (file_path and content and extension)):
  error_msg = 'Must provide `file_path` or `content` and `extension`'
  raise Exception(error_msg)
 if (file_path and (content is None) and (extension is None)):
  extension = os.path.splitext(file_path)[1]
  with open(file_path) as infile:
   content = infile.read()
 if (extension in ['.css']):
  regex = re.compile('([^a-zA-Z-])')
 elif (extension in ['.R', '.c', 'md', '.cpp, java', '.py']):
  regex = re.compile('([^a-zA-Z_])')
 else:
  regex = re.compile('([^a-zA-Z])')
 words = sorted(set(regex.sub(' ', content).split()))
 return words

def get_words ( file_path = None , content = None , extension = None ) : if ( ( ( file_path is None ) and ( ( content is None ) or ( extension is None ) ) ) or ( file_path and content and extension ) ) : error_msg = 'Must provide `file_path` or `content` and `extension`' raise Exception ( error_msg ) if ( file_path and ( content is None ) and ( extension is None ) ) : extension = os . path . splitext ( file_path ) [ 1 ] with open ( file_path ) as infile : content = infile . read ( ) if ( extension in [ '.css' ] ) : regex = re . compile ( '([^a-zA-Z-])' ) elif ( extension in [ '.R' , '.c' , 'md' , '.cpp, java' , '.py' ] ) : regex = re . compile ( '([^a-zA-Z_])' ) else : regex = re . compile ( '([^a-zA-Z])' ) words = sorted ( set ( regex . sub ( ' ' , content ) . split ( ) ) ) return words
extract all words from a source code file to be used in code completion .