def IdentifyCompany(filename): print "\n\nIdentifying the company\n" print "-----------------------" po.companies = po.set_companies() company = None f = re.sub(r"(data\\)?\d+\s*\-\s*\w{3}\s*\-\s*(.*?)\b", '', filename) f = re.sub(r'\.\w+', '', f) #l = str(f).split() pattern = "(.*?)" + str(f) + "(.*?)" for c in po.companies: m = re.match(pattern, c.getname(), re.IGNORECASE) if m is not None: company = c if company == None: company = CompanyOptions() else: resp = None while not resp: resp = raw_input("\nFound company '" + company.getname() + "'. Is this correct [y/n]: ") if not re.match("y|n", resp): print "Invalid entry. Expecting a 'y' or 'n'" resp = None if re.match("no?", resp): company = CompanyOptions() return company
def IdentifyCompany(filename): print "\n\nIdentifying the company\n" print "-----------------------" po.companies = po.set_companies() company = None f = re.sub(r"(data\\)?\d+\s*\-\s*\w{3}\s*\-\s*(.*?)\b",'',filename) f = re.sub(r'\.\w+','',f) #l = str(f).split() pattern = "(.*?)"+str(f)+"(.*?)" for c in po.companies: m = re.match(pattern,c.getname(),re.IGNORECASE) if m is not None: company = c if company == None: company = CompanyOptions() else: resp = None while not resp: resp = raw_input("\nFound company '"+company.getname()+"'. Is this correct [y/n]: ") if not re.match("y|n", resp): print "Invalid entry. Expecting a 'y' or 'n'" resp = None if re.match("no?", resp): company = CompanyOptions() return company