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)
Enhanced error output to extra module dda37a22d21db1af6330fd62395682b91f46f5ec Sebastian Fricke 2020-01-27 10:56:00
Introduction infoPrint, removed unnecessary parameter 98b6779f95fcf6d3350f64e7d2a8151932415458 Sebastian Fricke 2020-01-16 14:27:15
Add Cdiscount price & coding style review 7c5451b067760100904aed947b2ba484ab9c9e45 Sebastian Fricke 2020-01-16 14:25:15
coding style, naming conventions & uninitialized 218378ca191510dc2092108a87e63ff83b4c6b31 Sebastian Fricke 2020-01-16 13:58:24
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
Commit dda37a22d21db1af6330fd62395682b91f46f5ec - Enhanced error output to extra module
moved errorPrint, warnPrint, infoPrint to error.py
module and fixed import errors in the category, price and
image module.
Author: Sebastian Fricke
Author date (UTC): 2020-01-27 10:56
Committer name: Sebastian Fricke
Committer date (UTC): 2020-01-27 10:56
Parent(s): 98b6779f95fcf6d3350f64e7d2a8151932415458
Signing key:
Tree: 5f1561a10aa321b8ac3260e1c359c84f9c314ad6
File Lines added Lines deleted
packages/category.py 8 9
packages/error.py 52 0
packages/image_upload.py 19 13
packages/item_upload.py 26 73
packages/price_upload.py 7 6
File packages/category.py changed (mode: 100644) (index a0c460f..b31eb5d)
12 12
13 13 import os import os
14 14 import sys import sys
15 from packages.item_upload import checkEncoding, errorPrint, warnPrint
16 from packages.config import get_path
15 from packages import item_upload, error, config
17 16
18 17 class CategoryConfig(object): class CategoryConfig(object):
19 18 """ """
 
... ... class CategoryConfig(object):
44 43 try: try:
45 44 self.path['path'] = os.path.join(root, 'category') self.path['path'] = os.path.join(root, 'category')
46 45 except (ValueError, Exception) as err: except (ValueError, Exception) as err:
47 errorPrint("Building path failed",
46 error.errorPrint("Building path failed",
48 47 err, sys.exc_info()[2].tb_lineno) err, sys.exc_info()[2].tb_lineno)
49 48 return False return False
50 49
51 50 if os.path.isfile(self.path['path']): if os.path.isfile(self.path['path']):
52 self.path = checkEncoding(self.path)
51 self.path = item_upload.checkEncoding(self.path)
53 52 return True return True
54 53
55 54 try: try:
56 self.path['path'] = get_path(message='category config path',
55 self.path['path'] = config.getPath(message='category config path',
57 56 path_type='file', path_type='file',
58 57 initialdir=root) initialdir=root)
59 self.path = checkEncoding(self.path)
58 self.path = item_upload.checkEncoding(self.path)
60 59 except (ValueError, Exception) as err: except (ValueError, Exception) as err:
61 errorPrint("searching file failed",
60 error.errorPrint("searching file failed",
62 61 err, sys.exc_info()[2].tb_lineno) err, sys.exc_info()[2].tb_lineno)
63 62
64 63 if not self.path['path']: if not self.path['path']:
 
... ... class CategoryConfig(object):
79 78 self.raw_data =\ self.raw_data =\
80 79 [row.strip(' ').strip('\n').split(';') for row in config] [row.strip(' ').strip('\n').split(';') for row in config]
81 80 except (ValueError, Exception) as err: except (ValueError, Exception) as err:
82 errorPrint("raw data read failed",
81 error.errorPrint("raw data read failed",
83 82 err, sys.exc_info()[2].tb_lineno) err, sys.exc_info()[2].tb_lineno)
84 83 return len(self.raw_data) > 0 return len(self.raw_data) > 0
85 84
 
... ... class CategoryConfig(object):
98 97 try: try:
99 98 self.id_list[option[0]] = int(option[1]) self.id_list[option[0]] = int(option[1])
100 99 except ValueError as err: except ValueError as err:
101 warnPrint("Integer conversion failed",
100 error.warnPrint("Integer conversion failed",
102 101 sys.exc_info()[2].tb_lineno, err) sys.exc_info()[2].tb_lineno, err)
103 102 else: else:
104 103 return False return False
File packages/error.py added (mode: 100644) (index 0000000..35b8e0d)
1 try:
2 import colorama
3 except ImportError as err:
4 print("colorama module required for enhanced error display")
5
6
7 try:
8 def errorPrint(msg, err, linenumber):
9 print(colorama.Fore.LIGHTRED_EX)
10 if err:
11 print("ERROR:\nline:{0}\t{1}\tError:{2}"
12 .format(linenumber, msg, err))
13 else:
14 print("ERROR:\nline:{0}\t{1}"
15 .format(linenumber, msg))
16 print(colorama.Style.RESET_ALL)
17 except AttributeError:
18 def errorPrint(msg, err, linenumber):
19 if err:
20 print("ERROR:\nline:{0}\t{1}\tError:{2}"
21 .format(linenumber, msg, err))
22 else:
23 print("ERROR:\nline:{0}\t{1}"
24 .format(linenumber, msg))
25
26 try:
27 def warnPrint(msg, err, linenumber):
28 print(colorama.Fore.YELLOW)
29 if err:
30 print("WARNING:\nline:{0}\t{1}\tWarning:{2}"
31 .format(linenumber, msg, err))
32 else:
33 print("WARNING:\nline:{0}\t{1}"
34 .format(linenumber, msg))
35 print(colorama.Style.RESET_ALL)
36 except AttributeError:
37 def warnPrint(msg, linenumber, err=''):
38 if err:
39 print("WARNING:\nline:{0}\t{1}\tWarning:{2}"
40 .format(linenumber, msg, err))
41 else:
42 print("WARNING:\nline:{0}\t{1}"
43 .format(linenumber, msg))
44
45 try:
46 def infoPrint(msg):
47 print(colorama.Fore.LIGHTBLUE_EX)
48 print(f"INFO:{msg}\n")
49 print(colorama.Style.RESET_ALL)
50 except AttributeError:
51 def infoPrint(msg):
52 print(f"INFO:{msg}\n")
File packages/image_upload.py changed (mode: 100644) (index 439c2c9..8cba657)
... ... import re
3 3 import sys import sys
4 4 import inspect import inspect
5 5 from sortedcontainers import SortedDict from sortedcontainers import SortedDict
6 from packages import item_upload, barcode
7 from packages.item_upload import errorPrint, warnPrint
6 from packages import item_upload, barcode, error
8 7
9 8 def searchSpecialImage(image): def searchSpecialImage(image):
10 9 return bool(re.search(r'( SWATCH|SIZE )', image)) return bool(re.search(r'( SWATCH|SIZE )', image))
 
... ... def getColorAttributeID(attributefile, product):
21 20 if row['AttributeValue.backendName'] == product['color_name']: if row['AttributeValue.backendName'] == product['color_name']:
22 21 attributeid = row['AttributeValue.id'] attributeid = row['AttributeValue.id']
23 22 if not attributeid: 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)
23 warn =\
24 f"Color{product['color_name']} not in {product['item_sku']}\n"
25 error.warnPrint(
26 msg=warn,
27 linenumber=inspect.currentframe().f_back.f_lineno)
27 28 except KeyError as err: except KeyError as err:
28 errorPrint("key not found in attribute file", err,
29 sys.exc_info()[2].tb_lineno)
29 error.errorPrint(
30 msg="key not found in attribute file",
31 err=err,
32 linenumber=sys.exc_info()[2].tb_lineno)
30 33
31 34 return attributeid return attributeid
32 35
 
... ... def imageUpload(flatfile, attributefile, exportfile, uploadfolder, filename):
82 85
83 86
84 87 except Exception as err: except Exception as err:
85 errorPrint("Link string building failed", err,
86 sys.exc_info()[2].tb_lineno)
88 error.errorPrint(msg="Link string building failed",
89 err=err,
90 linenumber=sys.exc_info()[2].tb_lineno)
87 91
88 92 try: try:
89 93 attribute_id = getColorAttributeID( attribute_id = getColorAttributeID(
90 94 attributefile=attributefile, product=row) attributefile=attributefile, product=row)
91 95 except Exception as err: except Exception as err:
92 warnPrint(
93 f"get attribute ID of color {row['color_name']} failed",
96 error.warnPrint(
97 msg=f"get attr ID of color {row['color_name']} failed",
94 98 linenumber=inspect.currentframe().f_back.f_lineno, linenumber=inspect.currentframe().f_back.f_lineno,
95 99 err=err) err=err)
96 100
 
... ... def imageUpload(flatfile, attributefile, exportfile, uploadfolder, filename):
101 105 data[row['item_sku']] = dict(zip(column_names, values)) data[row['item_sku']] = dict(zip(column_names, values))
102 106
103 107 except Exception as err: except Exception as err:
104 errorPrint(f"flatfile read failed on index:{index}",
105 err, sys.exc_info()[2].tb_lineno)
108 error.errorPrint(
109 msg=f"flatfile read failed on index:{index}",
110 err=err,
111 linenumber=sys.exc_info()[2].tb_lineno)
106 112
107 113 barcode.writeCSV(dataobject=data, name='Image_', columns=column_names, barcode.writeCSV(dataobject=data, name='Image_', columns=column_names,
108 114 upload_path=uploadfolder, item=filename) upload_path=uploadfolder, item=filename)
File packages/item_upload.py changed (mode: 100644) (index 85715b1..381919e)
... ... import re
4 4 import collections import collections
5 5 import inspect import inspect
6 6 import chardet import chardet
7 import colorama
8 from packages import barcode, amazon_data_upload, price_upload
7 from packages import barcode, amazon_data_upload, price_upload, error
9 8
10 9
11 10 class WrongEncodingException(Exception): class WrongEncodingException(Exception):
12 11 pass pass
13 12
14 try:
15 def errorPrint(msg, err, linenumber):
16 print(colorama.Fore.LIGHTRED_EX)
17 if err:
18 print("ERROR:\nline:{0}\t{1}\tError:{2}"
19 .format(linenumber, msg, err))
20 else:
21 print("ERROR:\nline:{0}\t{1}"
22 .format(linenumber, msg))
23 print(colorama.Style.RESET_ALL)
24 except AttributeError:
25 def errorPrint(msg, err, linenumber):
26 if err:
27 print("ERROR:\nline:{0}\t{1}\tError:{2}"
28 .format(linenumber, msg, err))
29 else:
30 print("ERROR:\nline:{0}\t{1}"
31 .format(linenumber, msg))
32
33 try:
34 def warnPrint(msg, err, linenumber):
35 print(colorama.Fore.YELLOW)
36 if err:
37 print("WARNING:\nline:{0}\t{1}\tWarning:{2}"
38 .format(linenumber, msg, err))
39 else:
40 print("WARNING:\nline:{0}\t{1}"
41 .format(linenumber, msg))
42 print(colorama.Style.RESET_ALL)
43 except AttributeError:
44 def warnPrint(msg, linenumber, err=''):
45 if err:
46 print("WARNING:\nline:{0}\t{1}\tWarning:{2}"
47 .format(linenumber, msg, err))
48 else:
49 print("WARNING:\nline:{0}\t{1}"
50 .format(linenumber, msg))
51
52 try:
53 def infoPrint(msg):
54 print(colorama.Fore.LIGHTBLUE_EX)
55 print(f"INFO:{msg}\n")
56 print(colorama.Style.RESET_ALL)
57 except AttributeError:
58 def infoPrint(msg):
59 print(f"INFO:{msg}\n")
60 13
61 14 def itemUpload(flatfile, intern, stocklist, folder, input_data, filename): def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
62 15 column_names = ['Parent-SKU', 'SKU', column_names = ['Parent-SKU', 'SKU',
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
114 67 try: try:
115 68 raise barcode.EmptyFieldWarning('generic_keywords') raise barcode.EmptyFieldWarning('generic_keywords')
116 69 except Exception: except Exception:
117 warnPrint("Generic Keywords are empty!",
70 error.warnPrint("Generic Keywords are empty!",
118 71 inspect.currentframe().f_back.f_lineno) inspect.currentframe().f_back.f_lineno)
119 72
120 73 try: try:
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
130 83 if(group_parent and row['parent_sku'] == group_parent): if(group_parent and row['parent_sku'] == group_parent):
131 84 position += 1 position += 1
132 85 except Exception as err: except Exception as err:
133 warnPrint("Attribute setting failed",
86 error.warnPrint("Attribute setting failed",
134 87 sys.exc_info()[2].tb_lineno, err) sys.exc_info()[2].tb_lineno, err)
135 88 try: try:
136 89 values = [ values = [
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
163 116 ] ]
164 117
165 118 except KeyError as kerr: except KeyError as kerr:
166 warnPrint('itemUpload: key not found in flatfile',
119 error.warnPrint('itemUpload: key not found in flatfile',
167 120 inspect.currentframe().f_back.f_lineno, inspect.currentframe().f_back.f_lineno,
168 121 err=kerr) err=kerr)
169 122 raise KeyError raise KeyError
170 123 except Exception as err: except Exception as err:
171 errorPrint("itemUpload: setting values failed", err,
124 error.errorPrint("itemUpload: setting values failed", err,
172 125 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
173 126 data[row['item_sku']] = collections.OrderedDict(zip(column_names, values)) data[row['item_sku']] = collections.OrderedDict(zip(column_names, values))
174 127 except KeyError as err: except KeyError as err:
175 errorPrint("Reading file failed", err,
128 error.errorPrint("Reading file failed", err,
176 129 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
177 130 return row['item_sku'] return row['item_sku']
178 131
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
184 137 if row['amazon_sku'] in list(data.keys()): if row['amazon_sku'] in list(data.keys()):
185 138 data[row['amazon_sku']]['ExternalID'] = row['full_number'] data[row['amazon_sku']]['ExternalID'] = row['full_number']
186 139 except KeyError as keyerr: except KeyError as keyerr:
187 warnPrint("key was not found in intern number list",
140 error.warnPrint("key was not found in intern number list",
188 141 sys.exc_info()[2].tb_lineno, keyerr) sys.exc_info()[2].tb_lineno, keyerr)
189 142
190 143 # Include the barcodes & asin # Include the barcodes & asin
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
199 152 data[row]['ASIN-type'] = barcode_data[row]['ASIN-type'] data[row]['ASIN-type'] = barcode_data[row]['ASIN-type']
200 153 data[row]['ASIN-value'] = barcode_data[row]['ASIN-value'] data[row]['ASIN-value'] = barcode_data[row]['ASIN-value']
201 154 except Exception as err: except Exception as err:
202 errorPrint("Barcode part for "+row, err,
155 error.errorPrint("Barcode part for "+row, err,
203 156 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
204 157
205 158 # Include the amazonsku # Include the amazonsku
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
213 166 data[row]['amazon_sku'] = sku_data[row]['SKU'] data[row]['amazon_sku'] = sku_data[row]['SKU']
214 167 data[row]['amazon_parentsku'] = sku_data[row]['ParentSKU'] data[row]['amazon_parentsku'] = sku_data[row]['ParentSKU']
215 168 except Exception as err: except Exception as err:
216 errorPrint("SKU part for "+row, err,
169 error.errorPrint("SKU part for "+row, err,
217 170 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
218 171
219 172 # Include the amazonsku # Include the amazonsku
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
226 179 data[row]['fba-enabled'] = ama_data[row]['ItemAmazonFBA'] data[row]['fba-enabled'] = ama_data[row]['ItemAmazonFBA']
227 180 data[row]['fba-shipping'] = ama_data[row]['ItemShippingWithAmazonFBA'] data[row]['fba-shipping'] = ama_data[row]['ItemShippingWithAmazonFBA']
228 181 except Exception as err: except Exception as err:
229 errorPrint("Amazondata part for "+row, err,
182 error.errorPrint("Amazondata part for "+row, err,
230 183 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
231 184
232 185 # Include the price # Include the price
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
241 194 data[row]['webshop-price'] = price_data[row]['webshop'] data[row]['webshop-price'] = price_data[row]['webshop']
242 195 data[row]['etsy-price'] = price_data[row]['etsy'] data[row]['etsy-price'] = price_data[row]['etsy']
243 196 except Exception as err: except Exception as err:
244 errorPrint("Price part for "+row, err,
197 error.errorPrint("Price part for "+row, err,
245 198 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
246 199
247 200 # Sort the dictionary to make sure that the parents are the first variant of each item # Sort the dictionary to make sure that the parents are the first variant of each item
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
249 202
250 203 barcode.writeCSV(sorted_data, "item", column_names, folder, filename) barcode.writeCSV(sorted_data, "item", column_names, folder, filename)
251 204 except UnicodeDecodeError as err: except UnicodeDecodeError as err:
252 errorPrint("decoding problem", err,
205 error.errorPrint("decoding problem", err,
253 206 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
254 207 print("press ENTER to continue..") print("press ENTER to continue..")
255 208 input() input()
 
... ... def itemPropertyUpload(flatfile, folder, filename):
301 254 [i for i in property_names if i in list(row.keys())] [i for i in property_names if i in list(row.keys())]
302 255 values = [row[i] for i in use_names] values = [row[i] for i in use_names]
303 256 except ValueError as err: except ValueError as err:
304 warnPrint("No Value",
257 error.warnPrint("No Value",
305 258 sys.exc_info()[2].tb_lineno, err) sys.exc_info()[2].tb_lineno, err)
306 259
307 260 # Check for empty values # Check for empty values
 
... ... def itemPropertyUpload(flatfile, folder, filename):
317 270
318 271 data[row + prop] = dict(zip(column_names, values)) data[row + prop] = dict(zip(column_names, values))
319 272 except KeyError as kerr: except KeyError as kerr:
320 errorPrint("Key was not found in the flatfile", kerr,
273 error.errorPrint("Key was not found in the flatfile", kerr,
321 274 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
322 275
323 276
 
... ... def getProperties(flatfile):
357 310 properties['width'] = int(float(row['package_width'])) properties['width'] = int(float(row['package_width']))
358 311 properties['weight'] = int(float(row['package_weight'])) properties['weight'] = int(float(row['package_weight']))
359 312 except ValueError as err: except ValueError as err:
360 errorPrint("Parent has no package measurements", err,
313 error.errorPrint("Parent has no package measurements", err,
361 314 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
362 315 sys.exit() sys.exit()
363 316 except Exception as err: except Exception as err:
364 errorPrint("getProperties setting values failed", err,
317 error.errorPrint("getProperties setting values failed", err,
365 318 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
366 319
367 320 return properties return properties
 
... ... def getAttributes(dataset, sets):
377 330 print("{0} not found in {1}" print("{0} not found in {1}"
378 331 .format(dataset['parent_sku'], ','.join(list(sets.keys())))) .format(dataset['parent_sku'], ','.join(list(sets.keys()))))
379 332 except Exception as err: except Exception as err:
380 errorPrint("Adding of color attribute failed", err,
333 error.errorPrint("Adding of color attribute failed", err,
381 334 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
382 335 try: try:
383 336 if len(sets[dataset['parent_sku']]['size']) > 1: if len(sets[dataset['parent_sku']]['size']) > 1:
 
... ... def getAttributes(dataset, sets):
386 339 else: else:
387 340 output_string = output_string + ';size_name:' + dataset['size_name'] output_string = output_string + ';size_name:' + dataset['size_name']
388 341 except Exception as err: except Exception as err:
389 errorPrint("Adding of size attribute failed", err,
342 error.errorPrint("Adding of size attribute failed", err,
390 343 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
391 344 return output_string return output_string
392 345
 
... ... def checkFlatfile(flatfile):
447 400
448 401 first_row = [*list(reader)[0]] first_row = [*list(reader)[0]]
449 402 if len(first_row) == 1: if len(first_row) == 1:
450 errorPrint("Wrong delimiter, use ';'",
403 error.errorPrint("Wrong delimiter, use ';'",
451 404 'False delimiter detected', 'False delimiter detected',
452 405 inspect.currentframe().f_back.f_lineno) inspect.currentframe().f_back.f_lineno)
453 406 return False return False
454 407
455 408 if not 'feed_product_type' in first_row: if not 'feed_product_type' in first_row:
456 409 if 'Marke' in first_row: if 'Marke' in first_row:
457 errorPrint("Only use the last of the 3 header lines",
410 error.errorPrint("Only use the last of the 3 header lines",
458 411 err='', err='',
459 412 linenumber=inspect.currentframe() linenumber=inspect.currentframe()
460 413 .f_back.f_lineno) .f_back.f_lineno)
461 414 print("Please cut the first two rows from the flatfile for this script\n") print("Please cut the first two rows from the flatfile for this script\n")
462 415 return False return False
463 errorPrint("Wrong header line", err='',
416 error.errorPrint("Wrong header line", err='',
464 417 linenumber=inspect.currentframe().f_back.f_lineno) linenumber=inspect.currentframe().f_back.f_lineno)
465 418 return False return False
466 419 return True return True
467 420
468 421 except Exception as err: except Exception as err:
469 warnPrint("Flatfile check failed",
422 error.warnPrint("Flatfile check failed",
470 423 sys.exc_info()[2].tb_lineno, err) sys.exc_info()[2].tb_lineno, err)
471 424
472 425 def checkEncoding(file_dict): def checkEncoding(file_dict):
 
... ... def checkEncoding(file_dict):
476 429 raw_data = item.read() raw_data = item.read()
477 430 except Exception as err: except Exception as err:
478 431 print("ERROR: {0}\n".format(err)) print("ERROR: {0}\n".format(err))
479 errorPrint("check Encoding reading failed", err,
432 error.errorPrint("check Encoding reading failed", err,
480 433 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
481 434 file_dict['encoding'] = chardet.detect(raw_data)['encoding'] file_dict['encoding'] = chardet.detect(raw_data)['encoding']
482 435 print("chardet data for {0}\n{1}\n".format(file_dict['path'], chardet.detect(raw_data))) print("chardet data for {0}\n{1}\n".format(file_dict['path'], chardet.detect(raw_data)))
483 436
484 437 except Exception as err: except Exception as err:
485 errorPrint("check Encoding failed", err,
438 error.errorPrint("check Encoding failed", err,
486 439 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
487 440
488 441 return file_dict return file_dict
 
... ... def getVariationId(exportfile, sku):
509 462 row[list(row.keys())[i]])) row[list(row.keys())[i]]))
510 463 variationid = row[list(row.keys())[i]] variationid = row[list(row.keys())[i]]
511 464 except Exception as err: except Exception as err:
512 errorPrint("Looking for irregularities in getVariationId",
465 error.errorPrint("Looking for irregularities in getVariationId",
513 466 err, sys.exc_info()[2].tb_lineno) err, sys.exc_info()[2].tb_lineno)
514 467 print("press ENTER to continue...") print("press ENTER to continue...")
515 468 input() input()
516 469 if not variationid: if not variationid:
517 warnPrint(msg="No Variation ID found for "+sku,
470 error.warnPrint(msg="No Variation ID found for "+sku,
518 471 linenumber=inspect.currentframe().f_back.f_lineno) linenumber=inspect.currentframe().f_back.f_lineno)
519 472
520 473 return variationid return variationid
File packages/price_upload.py changed (mode: 100644) (index e581288..b901adf)
1 1 import inspect import inspect
2 2 from collections import OrderedDict from collections import OrderedDict
3 3 from csv import DictReader from csv import DictReader
4 from packages.item_upload import warnPrint, infoPrint
4 from packages import error
5 5
6 6
7 7 def priceUpload(flatfile): def priceUpload(flatfile):
 
... ... def priceUpload(flatfile):
31 31 for row in reader: for row in reader:
32 32 # Make sure that there is price even at parents # Make sure that there is price even at parents
33 33 if not row['standard_price']: if not row['standard_price']:
34 warnPrint(f"row:{row['item_sku']} doesnt have a price!",
35 linenumber=inspect.currentframe().f_back.f_lineno,
36 err='')
34 error.warnPrint(
35 msg=f"row:{row['item_sku']} doesnt have a price!",
36 linenumber=inspect.currentframe().f_back.f_lineno,
37 err='')
37 38 for scndrow in reader: for scndrow in reader:
38 39 if row['parent_child'] == 'parent': if row['parent_child'] == 'parent':
39 40 if scndrow['parent_child'] == 'child' and\ if scndrow['parent_child'] == 'child' and\
 
... ... def priceUpload(flatfile):
58 59
59 60 for row in reader: for row in reader:
60 61 if row['standard_price']: if row['standard_price']:
61 variation_price = row['standard_price']
62 variation_price = float(row['standard_price'])
62 63 else: else:
63 variation_price = standard_price
64 variation_price = float(standard_price)
64 65 for price in prices: for price in prices:
65 66 if prices[price]['id'] == '3': if prices[price]['id'] == '3':
66 67 percent_diff = 0.10 percent_diff = 0.10
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