initBasti / Amazon2PlentySync (public) (License: GPLv3) (since 2019-01-27) (hash sha1)
Transfer your data from you Amazon Flatfile spreadsheet over to the Plentymarkets system. How to is included in the readme
List of commits:
Subject Hash Author Date (UTC)
coding style & cleanup image upload module 04ac13fb764baecd1a419cbffcd9696a3ff5b680 Sebastian Fricke 2020-01-16 13:56:07
coding style improvements and colorful error msg 401db811c0edd62b14c7a0a29e2c1f6d2791774c Sebastian Fricke 2020-01-16 13:54:25
code cleanup and coding style category.py b1e41b45fe405d3826a9b6e452fb9e2f9f6697bf Sebastian Fricke 2020-01-16 10:43:44
Added the category config to the gitignore file b8b522d9ade4b59b5d0a0bd4f9b7c79e8db334c6 Sebastian Fricke 2020-01-15 14:56:06
Removed log function for category_config(not needed) c8ca8a3b6b968f1835697073e7d5fe1ea70b15ba Sebastian Fricke 2020-01-15 14:54:15
Added category_config functionality 7bd8256398b4af5c1feb3033d74cd9f29b047edc Sebastian Fricke 2020-01-15 14:53:20
improved error handling & adjusted names to naming convention cfcd91090a2598c6c51576bcdd53e03ab6c2f59b Sebastian Fricke 2020-01-15 14:47:42
Refactor CategoryChooser 562e6657c6fef89d0584731e54325cec013268a7 Sebastian Fricke 2020-01-15 14:42:11
Add category_config location to the script config 8698e4a99d63b06fde5c39787fc7d6f7400b9f47 Sebastian Fricke 2020-01-15 14:29:47
Refactor findConfig 321ae9d7edd69e8be0755cf5ba82289944d06ca3 Sebastian Fricke 2020-01-15 14:26:09
Add logging function: no category config warning e8323843a3b6c24ef274d6a12c10d76aa8b8f591 Sebastian Fricke 2020-01-14 14:38:39
Add module + test for the category-id config fadaf4515aab1009f4df4a1af5a2e8f82077bc4c Sebastian Fricke 2020-01-14 14:35:44
improved coding style on log functions caf97eec6c6026aa051bc98f02a90e649a6e4754 Sebastian Fricke 2020-01-14 10:23:17
fixed a typo in the product type list 707e993b953aea0d653ffbca136bbe81bb36ea13 Sebastian Fricke 2020-01-14 10:22:34
added home product properties, improved dictionary iteration, fixed a key error in get_attributes 30d4aed4403c39a6865e30c0384c3360d375cbb6 Sebastian Fricke 2020-01-14 10:21:56
removed warning for missing flatfile columns as requested bfe6e22f7acb282a3af8423c81ceacf9fcf21ef4 Sebastian Fricke 2020-01-13 15:05:27
added initialization for the position variable 8331f92d62deb9ba7be7e97201c7c6afa7cf732a Sebastian Fricke 2020-01-13 14:47:57
improved code style and fixed problem where the dictionary containing the path was given to functions instead of the path itself 1a5bf99751b599f48d4687a9a6cbd55ffe213f5a Sebastian Fricke 2020-01-13 14:47:13
removed Barcode missing warning on parents b592779c6cc1588e2ae40394cab53d0d047746e7 Sebastian Fricke 2020-01-13 14:46:16
Added support for the amazon product types furnitureanddecor, bedandbath, swimwear b56708e55c3283a6cc2d3803b2abbb99bb125928 Sebastian Fricke 2020-01-13 14:16:40
Commit 04ac13fb764baecd1a419cbffcd9696a3ff5b680 - coding style & cleanup image upload module
coding style review and cleanup using the PEP8 standard
simplified a few function calls
Author: Sebastian Fricke
Author date (UTC): 2020-01-16 13:56
Committer name: Sebastian Fricke
Committer date (UTC): 2020-01-16 13:56
Parent(s): 401db811c0edd62b14c7a0a29e2c1f6d2791774c
Signer:
Signing key:
Signing status: N
Tree: 1a7754aaeaa937794525cda83b585dc8ce540c49
File Lines added Lines deleted
packages/image_upload.py 53 45
File packages/image_upload.py changed (mode: 100644) (index 9f18cd2..439c2c9)
1 1 import csv import csv
2 from sortedcontainers import SortedDict
3 2 import re import re
4 3 import sys import sys
4 import inspect
5 from sortedcontainers import SortedDict
5 6 from packages import item_upload, barcode from packages import item_upload, barcode
7 from packages.item_upload import errorPrint, warnPrint
6 8
7 9 def searchSpecialImage(image): def searchSpecialImage(image):
8 if(re.search(r'( SWATCH|SIZE )', image)):
9 return True
10 else:
11 return False
10 return bool(re.search(r'( SWATCH|SIZE )', image))
12 11
13 12 def getColorAttributeID(attributefile, product): def getColorAttributeID(attributefile, product):
14 13
15 14 attributeid = '' attributeid = ''
16 with open(attributefile['path'], mode = 'r', encoding = attributefile['encoding']) as item:
15 with open(attributefile['path'],
16 mode='r', encoding=attributefile['encoding']) as item:
17 17 reader = csv.DictReader(item, delimiter=';') reader = csv.DictReader(item, delimiter=';')
18 18
19 19 try: try:
20 20 for row in reader: for row in reader:
21 if(row['AttributeValue.backendName'] == product['color_name']):
21 if row['AttributeValue.backendName'] == product['color_name']:
22 22 attributeid = row['AttributeValue.id'] attributeid = row['AttributeValue.id']
23 if(not( attributeid )):
24 print("For SKU : {0}, Color : {1} not found!\n".format(product['item_sku'], product['color_name']))
25 except Exception as err:
26 print("ERROR @ Color ID search: line: {0}, err: {1}".format(sys.exc_info()[2].tb_lineno, err))
23 if not attributeid:
24 warn = f"Color:{product['color_name']} not found in {product['item_sku']}!\n"
25 warnPrint(warn,
26 inspect.currentframe().f_back.f_lineno)
27 except KeyError as err:
28 errorPrint("key not found in attribute file", err,
29 sys.exc_info()[2].tb_lineno)
27 30
28 31 return attributeid return attributeid
29 32
 
... ... def getColorAttributeID(attributefile, product):
31 34 def imageUpload(flatfile, attributefile, exportfile, uploadfolder, filename): def imageUpload(flatfile, attributefile, exportfile, uploadfolder, filename):
32 35
33 36 try: try:
34 Data = SortedDict()
37 data = SortedDict()
35 38
36 39 column_names = ['VariationID', 'Multi-URL', 'connect-variation', 'mandant', column_names = ['VariationID', 'Multi-URL', 'connect-variation', 'mandant',
37 40 'listing', 'connect-color'] 'listing', 'connect-color']
38 attributeID = ''
41 attribute_id = ''
39 42 variation_id = 0 variation_id = 0
40 43
41 44 with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item: with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item:
42 45 reader = csv.DictReader(item, delimiter=';') reader = csv.DictReader(item, delimiter=';')
43 for index, row in enumerate( reader ):
46 for index, row in enumerate(reader):
44 47 linkstring = '' linkstring = ''
45 48 imglinks = [ imglinks = [
46 49 row['main_image_url'], row['main_image_url'],
 
... ... def imageUpload(flatfile, attributefile, exportfile, uploadfolder, filename):
55 58 ] ]
56 59
57 60 num = 1 num = 1
58 variation_id = item_upload.get_variationid(exportfile=exportfile, sku=row['item_sku'])
61 variation_id = item_upload.getVariationId(
62 exportfile=exportfile, sku=row['item_sku'])
59 63 try: try:
60 if(imglinks[0]):
61 for img in imglinks:
62 if(not(searchSpecialImage(img))):
63 if(not(linkstring)):
64 if(img):
65 linkstring += img + ';' + str( num )
66 num += 1
67 else:
68 if(img):
69 linkstring += ',' + img + ';' + str( num )
70 num += 1
71 if(searchSpecialImage(img)):
72 print("\n{0} is a special image\n".format(img))
73 if(not(linkstring)):
74 if(img):
75 linkstring += img + ';' + str( num )
76 num += 1
77 else:
78 if(img):
79 linkstring += ',' + img + ';' + str( num )
80 num += 1
64 if not imglinks[0]:
65 break
66 for img in [i for i in imglinks if i]:
67 if not searchSpecialImage(img):
68 if not linkstring:
69 linkstring += f"{img};{str(num)}"
70 num += 1
71 continue
72 linkstring += f",{img};{str(num)}"
73 num += 1
74 continue
75 print(f"\n{img} is a special image\n")
76 if not linkstring:
77 linkstring += f"{img};{str(num)}"
78 num += 1
79 continue
80 linkstring += f",{img};{str(num)}"
81 num += 1
81 82
82 83
83 84 except Exception as err: except Exception as err:
84 print("Error @ linkstring building line no: {0} : {1}".format(sys.exc_info()[2].tb_lineno, err))
85 errorPrint("Link string building failed", err,
86 sys.exc_info()[2].tb_lineno)
85 87
86 88 try: try:
87 attributeID = getColorAttributeID(attributefile=attributefile, product=row)
89 attribute_id = getColorAttributeID(
90 attributefile=attributefile, product=row)
88 91 except Exception as err: except Exception as err:
89 print("Error @ get Color Attribute ID {0}\n".format(err))
92 warnPrint(
93 f"get attribute ID of color {row['color_name']} failed",
94 linenumber=inspect.currentframe().f_back.f_lineno,
95 err=err)
90 96
91 97
92 values=[variation_id, linkstring, 1, -1,
93 -1, attributeID]
98 values = [variation_id, linkstring, 1, -1,
99 -1, attribute_id]
94 100
95 Data[row['item_sku']] = dict(zip(column_names, values))
101 data[row['item_sku']] = dict(zip(column_names, values))
96 102
97 103 except Exception as err: except Exception as err:
98 print("Error @ imageupload line: {0} : {1}".format(sys.exc_info()[2].tb_lineno, err))
104 errorPrint(f"flatfile read failed on index:{index}",
105 err, sys.exc_info()[2].tb_lineno)
99 106
100 barcode.writeCSV(dataobject=Data, name='Image_', columns=column_names, upload_path=uploadfolder, item=filename)
101 return Data
107 barcode.writeCSV(dataobject=data, name='Image_', columns=column_names,
108 upload_path=uploadfolder, item=filename)
109 return data
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/initBasti/Amazon2PlentySync

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/initBasti/Amazon2PlentySync

Clone this repository using git:
git clone git://git.rocketgit.com/user/initBasti/Amazon2PlentySync

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main