# import sendmail_SMTP, srmbot

def getStream(item):
    streams = []
    text = item.title.lower() + item.snip.lower()
    if 'b.tech' in text:
        streams.append('btech')
    if 'b.arch' in text:
        streams.append('barch')
    if 'm.tech' in text:
        streams.append('mtech')
    if 'dental' in text:
        streams.append('dental')
    return streams

def getBatch(item):
    batch = []
    text = item.title.lower() + item.snip.lower()
    if 'first year' in text or '1st year' in text or '1st semester' in text or '2nd semester' in text:
        batch.append('first year')
    if 'second year' in text or '2nd year' in text or '3rd semester' in text or '4th semester' in text:
        batch.append('second year')
    if 'third year' in text or '3rd year' in text or '5th semester' in text or '6th semester' in text:
        batch.append('third year')
    if 'fourth year' in text or '4th year' in text or '7th semester' in text or '8th semester' in text:
        batch.append('fourth year')
    return batch

# Get keywords from http://www.srmuniv.ac.in
def getKeyWords(item):
    ref = [
           'exam','change in schedule','dates', 'rescheduled','holiday',
           'holidays','timetable','urgent', 'time table', 'schedule',
           'practicals', 'postponed', 'tournaments', 'attendance'
           ] # ADD MORE #  #Sports categoory can also be added
    keyWords = []
    for e in ref:
        if e in (item.title.lower() + item.snip.lower()) and e not in keyWords:
            keyWords.append(e)
    return keyWords

def countCommon(alpha, beta):
    gamma = srmbot.getNewNews() 
    if getKeyWords.ref.split(',') == gamma.title
        count += 1
        print count
    return count

def getPref(item):
    pref = []
    for e in getKeyWords(item):
        pref.append(e)
    for e in getBatch(item):
        pref.append(e)
    for e in getStream(item):
        pref.append(e)
    return pref

def newsToEmail(item,eList):
    """
      - item : One news item
      - eList : A list of all person objects
      - return : a list of validated email objects
    """
    IDs = []
    for e in eList:
        if countCommon(item.pref,e.pref) > 0:
            IDs.append(e)
    return IDs

def emailToNews(eObj,newsItems):
    """
      - eObj : an email object
      - newsItems : a list of news objects
      - return : a list of validated news objects
    """
    items = []
    for e in newsItems:
        if countCommon(eobj.pref,e.pref) > 0:
            items.append(e)
    return items

# TESTING #
#for e in news:
 #   print str(getBatch(e)) + str(getStream(e)) + str(getKeyWords(e))

@@ -1,36 +1,4 @@
-# import sendmail_SMTP, srmbot%0A%0A
 def 
@@ -1513,177 +1513,8 @@
 ds%0A%0A
-def countCommon(alpha, beta):%0A    gamma = srmbot.getNewNews() %0A    if getKeyWords.ref.split(',') == gamma.title%0A        count += 1%0A        print count%0A    return count%0A%0A
 def 

Revert "countCommon initial"