Subject | Hash | Author | Date (UTC) |
---|---|---|---|
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 |
fix failing attribute sync | 87ea4bce17eba6c9c9842eaf9eb26249bf8d7da5 | Sebastian Fricke | 2020-01-13 12:15:35 |
new config handling | d65bdfae89eceab6b1319d01373cf70ac7d8b63e | Sebastian Fricke | 2019-11-13 08:57:14 |
Fixed a problem, that caused Data to not pass sorting; Fixed error handling with the product type; Updated category ids | 9a62d369fb24bc80765cd19e31fb255398fb8ed5 | Sebastian Fricke | 2019-09-12 09:27:54 |
fixed a merge conflict bug | e6b4d9613237009d980cdbfc7ec65c3383a3495a | Sebastian Fricke | 2019-08-16 11:31:02 |
current status 15.8 | 94db3a5c98c596b24f00624fa4b772b9fd830b03 | Sebastian Fricke | 2019-08-15 14:26:42 |
Added manual file choosing in case of empty config | 2df178528d70be15bfb2e1c9058f69e128236622 | Sebastian Fricke | 2019-08-15 10:11:41 |
Added Markdown choosing, fixed various bugs | 991ed44df370cf80fc2e2c51d7427d63e221888f | Sebastian Fricke | 2019-08-15 09:30:55 |
Changed the item upload format to fix errors in the sync, moved active upload to properties because it has to be done seperatly to the creation process | 3b466364e3dcdf14b4cef5b8649ec9573c992324 | Sebastian Fricke | 2019-06-17 14:09:23 |
Removed the image upload from item upload and added a exportfile together with functions to get the variation id for the image upload, the image upload is now a single process | 6349c4a7177345c25aa6d8ecd03740a75fa2520f | Sebastian Fricke | 2019-06-13 12:58:36 |
File | Lines added | Lines deleted |
---|---|---|
packages/category.py | 29 | 22 |
File packages/category.py changed (mode: 100644) (index 5a5431a..e6bc0ec) | |||
1 | from packages.item_upload import check_encoding | ||
2 | from packages.log_files import noCategoryFileLog | ||
1 | from packages.item_upload import checkEncoding | ||
2 | from packages.config import get_path | ||
3 | 3 | import os | import os |
4 | 4 | from pathlib import Path | from pathlib import Path |
5 | 5 | ||
6 | 6 | class CategoryConfig: | class CategoryConfig: |
7 | def __init__(self, proj_root, log_path): | ||
8 | self.root = proj_root | ||
9 | self.log = log_path | ||
7 | def __init__(self): | ||
10 | 8 | self.id_list = dict() | self.id_list = dict() |
11 | 9 | self.raw_data = [] | self.raw_data = [] |
12 | 10 | self.path = {'path':'', 'encoding':''} | self.path = {'path':'', 'encoding':''} |
13 | 11 | ||
14 | def findConfig(self): | ||
12 | def findConfig(self, root): | ||
15 | 13 | try: | try: |
16 | self.path['path'] = os.path.join(self.root, 'category') | ||
14 | self.path['path'] = os.path.join(root, 'category') | ||
17 | 15 | except Exception as err: | except Exception as err: |
18 | 16 | print("ERROR @ findCategoryConfig: Building path failed: {0}" | print("ERROR @ findCategoryConfig: Building path failed: {0}" |
19 | 17 | .format(err)) | .format(err)) |
20 | 18 | return False | return False |
21 | 19 | ||
22 | 20 | if(os.path.isfile(self.path['path'])): | if(os.path.isfile(self.path['path'])): |
23 | self.path['encoding'] = check_encoding(self.path) | ||
24 | with open(self.path['path'], | ||
25 | mode='r', encoding=self.path['encoding']) as config: | ||
26 | try: | ||
27 | self.raw_data =\ | ||
28 | [row.stip(' ').strip('\n').split(';') for row in config] | ||
29 | except Exception as err: | ||
30 | print("ERROR @ findCategoryConfig: Read data failed: {0}" | ||
31 | .format(err)) | ||
32 | |||
21 | self.path = check_encoding(self.path) | ||
33 | 22 | return True | return True |
34 | 23 | else: | else: |
35 | 24 | try: | try: |
36 | Path(self.path['path']).touch(mode=0o777,exist_ok=True) | ||
25 | self.path['path'] = get_path(message='category config path', | ||
26 | path_type='file', | ||
27 | initialdir=root) | ||
28 | self.path = check_encoding(self.path) | ||
37 | 29 | except Exception as err: | except Exception as err: |
38 | print("ERROR @ findCategoryConfig: creating file: {0}" | ||
30 | print("ERROR @ findCategoryConfig: searching file: {0}" | ||
39 | 31 | .format(err)) | .format(err)) |
40 | noCategoryFileLog(self.log, self.path['path']) | ||
41 | return False | ||
32 | if(not(self.path['path'])): | ||
33 | return False | ||
34 | else: | ||
35 | return True | ||
36 | |||
37 | |||
38 | def rawConfig(self): | ||
39 | with open(self.path['path'], | ||
40 | mode='r', encoding=self.path['encoding']) as config: | ||
41 | try: | ||
42 | self.raw_data =\ | ||
43 | [row.strip(' ').strip('\n').split(';') for row in config] | ||
44 | except Exception as err: | ||
45 | print("ERROR @ findCategoryConfig: Read data failed: {0}" | ||
46 | .format(err)) | ||
47 | return len(self.raw_data) > 0 | ||
42 | 48 | ||
43 | 49 | ||
44 | 50 | def readConfig(self): | def readConfig(self): |
45 | 51 | if(not(self.raw_data)): | if(not(self.raw_data)): |
46 | return False | ||
52 | if(not(self.rawConfig())): | ||
53 | return False | ||
47 | 54 | for row in self.raw_data: | for row in self.raw_data: |
48 | 55 | option = "".join(row).split('=') | option = "".join(row).split('=') |
49 | 56 | if(len(option[0]) > 1 and len(option[1]) > 1): | if(len(option[0]) > 1 and len(option[1]) > 1): |