PYTHON   90

keyword join py

Guest on 21st August 2022 08:39:24 AM

  1. import sys
  2. import keyword_scraper
  3.  
  4. '''
  5. Invokes keyword_scraper to sort a file of keywords
  6.        
  7. Example:
  8.  
  9.         $ python keyword_scraper_tool.py geshi_lang_file.php somedir
  10. '''
  11.  
  12. if len(sys.argv) < 2:
  13.         print "Usage: keyword_scraper_tool <inputfile> <outputfile>"
  14.         exit()
  15. else:
  16.         infile_ = sys.argv[1]
  17.         outfile_ = sys.argv[2] if len(sys.argv) >= 3 else None
  18.  
  19.         infile = open(infile_, 'r')
  20.         keywords = [x.strip() for x in infile.readlines()]
  21.         keywords.sort(keyword_scraper.cmp_keywords)
  22.  
  23.         if outfile_:
  24.                 outfile = open(outfile_, 'w')
  25.                 outfile.write('\n'.join(keywords))

Raw Paste


Login or Register to edit or fork this paste. It's free.