Esempio n. 1
0
    def test_AddCompany(self):
        n = Network()
        companyid = "company"
        companyid2 = "company"
        companyid3 = "company3"
        c = Company(companyid)
        c2 = Company(companyid2)

        n.AddCompany(c)

        with self.assertRaises(Exception):
            n.AddCompany(c2)

        n.AddCompanyByDef(companyid3, False, False)

        self.assertEqual(n.Companies[companyid].ID, companyid)
        self.assertEqual(n.Companies[companyid3].ID,  companyid3)
        return
Esempio n. 2
0
    def ImportCompanies(self, network: Network):

        filename = CompanyCSVStream.DefaultFileName
        if FileType.Company in self.CSVFileNames:
            filename = self.CSVFileNames[FileType.Company]

        propertymap = CompanyCSVStream.DefaultPropertyToFileMap
        if FileType.Company in self.CSVPropertyMaps:
            propertymap = self.CSVPropertyMaps[FileType.Company]

        with CompanyCSVStream(filename, propertymap, self.Encoding) as csv:
            i = 0
            d = 0
            for company in csv:
                network.AddCompanyByDef(csv.getCompanyName(),
                                        csv.getEnforceLosses(), csv.getAWR())
                i += 1
                while i > ((d + 1) * .10 * len(csv)):
                    print("", end='.')
                    d += 1
        return