Esempio n. 1
0
class CreateShops(object):

    def __init__(self, xls_file, xml):
        from modules.excel import CommonExcel
        path = "xls/express/{0}.xls".format(xls_file)
        self.excel = CommonExcel(path)
        self.xls_file = xls_file
        self.xml = xml

    def get(self):
        shop_look_ids = self.excel.read_excel_collumn(0, 1, 1)
        shop_look_names = self.excel.read_excel_collumn(1, 1, 1)
        shop_look_images = self.excel.read_excel_collumn_for_urls(2, 1, 1)
        self._create_shop_looks(shop_look_ids, shop_look_names, shop_look_images)

        shop_line_ids = self.excel.read_excel_collumn(0, 1, 2)
        shop_line_names = self.excel.read_excel_collumn(1, 1, 2)
        self._create_shop_lines(shop_line_ids, shop_line_names)

    def _create_shop_looks(self, ids, names, urls):
        item = ExpressItem()
        for i in range(0, len(ids)):
            item['product_id'] = [ids[i]]
            item['name'] = [basic.cdata(names[i])]
            item['normal_image_url'] = [basic.cdata(urls[i])]
            item['shop_look'] = ['True']
            item['normal'] = ['False']
            item['shop_line'] = ['False']
            item['in_stock'] = ['IN_STOCK']
            self.xml.create_xml(item)

    def _create_shop_lines(self, ids, names):
        item = ExpressItem()
        for i in range(0, len(ids)):
            item['product_id'] = [ids[i]]
            item['name'] = [basic.cdata(names[i])]
            item['shop_look'] = ['False']
            item['normal'] = ['False']
            item['shop_line'] = ['True']
            item['in_stock'] = ['IN_STOCK']
            self.xml.create_xml(item)
Esempio n. 2
0
class CreateShops(object):
    def __init__(self, xls_file, xml):
        from modules.excel import CommonExcel
        path = "xls/express/{0}.xls".format(xls_file)
        self.excel = CommonExcel(path)
        self.xls_file = xls_file
        self.xml = xml

    def get(self):
        shop_look_ids = self.excel.read_excel_collumn(0, 1, 1)
        shop_look_names = self.excel.read_excel_collumn(1, 1, 1)
        shop_look_images = self.excel.read_excel_collumn_for_urls(2, 1, 1)
        self._create_shop_looks(shop_look_ids, shop_look_names,
                                shop_look_images)

        shop_line_ids = self.excel.read_excel_collumn(0, 1, 2)
        shop_line_names = self.excel.read_excel_collumn(1, 1, 2)
        self._create_shop_lines(shop_line_ids, shop_line_names)

    def _create_shop_looks(self, ids, names, urls):
        item = ExpressItem()
        for i in range(0, len(ids)):
            item['product_id'] = [ids[i]]
            item['name'] = [basic.cdata(names[i])]
            item['normal_image_url'] = [basic.cdata(urls[i])]
            item['shop_look'] = ['True']
            item['normal'] = ['False']
            item['shop_line'] = ['False']
            item['in_stock'] = ['IN_STOCK']
            self.xml.create_xml(item)

    def _create_shop_lines(self, ids, names):
        item = ExpressItem()
        for i in range(0, len(ids)):
            item['product_id'] = [ids[i]]
            item['name'] = [basic.cdata(names[i])]
            item['shop_look'] = ['False']
            item['normal'] = ['False']
            item['shop_line'] = ['True']
            item['in_stock'] = ['IN_STOCK']
            self.xml.create_xml(item)
Esempio n. 3
0
 def get_lists_from_excel(self):
     xls = CommonExcel(basic.get_excel_path(self.name, self.d['file']))
     self.ordered = True
     try:
         self.url_list = xls.read_excel_collumn_for_urls(4, 1)
         self.id_list = xls.read_excel_collumn_for_ids(0, 1)
         self.shop_look_list = xls.read_excel_collumn(1, 1)
         self.shop_line_list = xls.read_excel_collumn(2, 1)
         try:
             self.order_list = xls.read_excel_collumn_for_ids(6, 1)
         except:
             self.ordered = False
             self.log.add_message("No order provided in this sheet.")
     except IOError as e:
         msg = "I/O error {0}: {1}".format(e.errno, e.strerror)
         msg += "\nError occurred for given file: {0}".format(self.d['file'])
         self.exc.code_handler(103, msg=msg)
     except StandardError:
         msg = "Error reading excel file"
         msg += "\nError occurred for given file: {0}".format(self.d['file'])
         self.exc.code_handler(103, msg=msg)
Esempio n. 4
0
 def __init__(self, xls_file, xml):
     from modules.excel import CommonExcel
     path = "xls/express/{0}.xls".format(xls_file)
     self.excel = CommonExcel(path)
     self.xls_file = xls_file
     self.xml = xml
Esempio n. 5
0
 def __init__(self, xls_file, xml):
     from modules.excel import CommonExcel
     path = "xls/express/{0}.xls".format(xls_file)
     self.excel = CommonExcel(path)
     self.xls_file = xls_file
     self.xml = xml