# coding=UTF-8
# -*- coding: UTF-8 -*-
import string, re
import os

import configs as config

def check_include_program(usefor, os, progname, catname, importance, page, targetos, lang, targetlang):
    """checks weather to include the program"""
    if os.strip() =='i' or targetos =='i' : internet_stuff = True;  # When we (for some reason) have no local install, but still want folks to know about good software
    else: internet_stuff = False;
    
    page_right = 0  ## checks if program fits for this html-page, which is now being generated
    if usefor.find('/')  > -1:
        usefor = usefor.split('/')[0];
        for i in range(len(usefor) ):
            if page.find(usefor[i] ) > -1: page_right = 1
    elif len(usefor) > 0 and page.find(usefor[0] ) > -1:  page_right = 1
    if ((os.find(targetos) !=-1) or internet_stuff ) and progname.strip() != '' and catname.strip() != '!!!': 
        ##print progname + ": importance = " + importance
        if page_right and ( not importance.strip() in ['', '?'] and int(importance) > config.importance_level):
            if lang == targetlang:
                return True
    
    return False
    


