Subversion Repositories SmartDukaan

Rev

Rev 5620 | Rev 9431 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5620 Rev 5971
Line 4... Line 4...
4
This script is used to load item details in the catalog database.
4
This script is used to load item details in the catalog database.
5
It's now mostly used for Accessories since they come in huge numbers.
5
It's now mostly used for Accessories since they come in huge numbers.
6
 
6
 
7
@author: Chandranshu
7
@author: Chandranshu
8
'''
8
'''
-
 
9
from elixir import *
-
 
10
from shop2020.model.v1.catalog.impl import DataService
-
 
11
from shop2020.model.v1.inventory.impl import DataService as IDataService
-
 
12
from shop2020.model.v1.catalog.impl.DataService import Item, EntityIDGenerator, \
9
import optparse
13
    ItemChangeLog
-
 
14
from shop2020.model.v1.inventory.impl.DataService import Vendor, \
-
 
15
    VendorItemMapping, VendorItemPricing
-
 
16
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemType
10
import csv
17
import csv
11
import xlrd
-
 
12
import datetime
18
import datetime
-
 
19
import optparse
-
 
20
import xlrd
13
 
21
 
14
if __name__ == '__main__' and __package__ is None:
22
if __name__ == '__main__' and __package__ is None:
15
    import sys
23
    import sys
16
    import os
24
    import os
17
    sys.path.insert(0, os.getcwd())
25
    sys.path.insert(0, os.getcwd())
18
 
26
 
19
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemType
-
 
20
from shop2020.model.v1.catalog.impl import DataService
-
 
21
from shop2020.model.v1.catalog.impl.DataService import Item, EntityIDGenerator,\
-
 
22
    ItemChangeLog, Vendor, VendorItemPricing, VendorItemMapping
-
 
23
from elixir import *
-
 
24
 
27
 
25
def load_item_data(filename, vendorId, full_update, dry_run):
28
def load_item_data(filename, vendorId, full_update, dry_run):
26
    DataService.initialize('catalog')
29
    DataService.initialize('catalog')
-
 
30
    IDataService.initialize('inventory')
27
    
31
 
28
    vendor = Vendor.get_by(id=vendorId)
32
    vendor = Vendor.get_by(id=vendorId)
29
    if vendor is None:
33
    if vendor is None:
30
        raise Exception("No vendor found for the id: " + str(vendorId))
34
        raise Exception("No vendor found for the id: " + str(vendorId))
31
    
35
    
32
    workbook = xlrd.open_workbook(filename)
36
    workbook = xlrd.open_workbook(filename)