|
7 | 7 | from utils import list_files |
8 | 8 | import confuse |
9 | 9 | import os, re |
10 | | -import ujson |
| 10 | +import ujson, yaml |
11 | 11 | import logging |
12 | 12 | from taxerapi import Configuration as TaxerConfig, ApiClient as TaxerClient, AccountApi as TaxerAccountApi, AccountsApi as TaxerAccountsApi, OperationApi as TaxerOperationApi \ |
13 | 13 | , Profile, User, UserBankAccount as ApiBankAccount |
14 | | -from utils import get_config_str |
| 14 | +from utils import get_config_str, get_config_int |
15 | 15 |
|
16 | 16 | @dataclass |
17 | 17 | class UserAccount: |
@@ -56,8 +56,9 @@ class DataDir(object): |
56 | 56 | accounts_fn:str = "accounts.json" |
57 | 57 | config_fn: str = "config.yaml" |
58 | 58 | default_rules_folder:str = 'rules' |
59 | | - default_input_folder:str = 'data' |
| 59 | + default_input_folder:str = 'data_in' |
60 | 60 | default_output_folder: str = 'data_out' |
| 61 | + default_first_row: int = 6 |
61 | 62 |
|
62 | 63 | def __init__(self, config:confuse.Configuration): |
63 | 64 | self.logger = logging.getLogger(__name__) |
@@ -158,6 +159,16 @@ def UpdateUsers(self): |
158 | 159 | if not os.path.exists(user_folder): |
159 | 160 | self.logger.debug(f'Creating folder {user_folder}') |
160 | 161 | os.mkdir(user_folder) |
| 162 | + # Store default config |
| 163 | + user_config: Dict = { |
| 164 | + 'datafile': { |
| 165 | + 'first_row': get_config_int(self.config, 'first_row', DataDir.default_first_row) |
| 166 | + }, |
| 167 | + 'input_folder': get_config_str(self.config, 'input_folder', DataDir.default_input_folder), |
| 168 | + 'output_folder': get_config_str(self.config, 'output_folder', DataDir.default_output_folder), |
| 169 | + } |
| 170 | + with open(self.user_config_path(u.id), encoding='utf8', mode='w') as f: |
| 171 | + yaml.dump(user_config, f) |
161 | 172 | self.create_folder_not_exists(self.user_folder_rules(u.id)) |
162 | 173 | self.create_folder_not_exists(self.user_folder_input(u.id)) |
163 | 174 | self.create_folder_not_exists(self.user_folder_output(u.id)) |
|
0 commit comments