csv2ofx 0.34.0__tar.gz → 0.34.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. {csv2ofx-0.34.0/csv2ofx.egg-info → csv2ofx-0.34.1}/PKG-INFO +3 -1
  2. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/main.py +42 -23
  3. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/ofx.py +23 -22
  4. {csv2ofx-0.34.0 → csv2ofx-0.34.1/csv2ofx.egg-info}/PKG-INFO +3 -1
  5. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx.egg-info/SOURCES.txt +1 -1
  6. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx.egg-info/requires.txt +2 -0
  7. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/pyproject.toml +3 -1
  8. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/tests/test_cli.py +37 -31
  9. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/LICENSE +0 -0
  10. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/MANIFEST.in +0 -0
  11. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/README.md +0 -0
  12. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/__init__.py +0 -0
  13. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/__main__.py +0 -0
  14. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/__init__.py +0 -0
  15. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/abnamro.py +0 -0
  16. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/amazon.py +0 -0
  17. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/boursorama.py +0 -0
  18. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/capitalone.py +0 -0
  19. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/creditunion.py +0 -0
  20. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/custom.py +0 -0
  21. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/default.py +0 -0
  22. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/eqbank.py +0 -0
  23. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/exim.py +0 -0
  24. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/gls.py +0 -0
  25. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/ingdirect.py +0 -0
  26. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/ingesp.py +0 -0
  27. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/mdb.py +0 -0
  28. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/mint.py +0 -0
  29. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/mint_extra.py +0 -0
  30. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/mint_headerless.py +0 -0
  31. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/mintapi.py +0 -0
  32. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/msmoneyreport.py +0 -0
  33. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/n26.py +0 -0
  34. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/outbank.py +0 -0
  35. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/payoneer.py +0 -0
  36. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/pcmastercard.py +0 -0
  37. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/rabobank.py +0 -0
  38. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/schwabchecking.py +0 -0
  39. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/split_account.py +0 -0
  40. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/starling.py +0 -0
  41. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/stripe.py +0 -0
  42. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/ubs-ch-fr.py +0 -0
  43. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/ubs.py +0 -0
  44. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/xero.py +0 -0
  45. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/mappings/yodlee.py +0 -0
  46. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/qif.py +0 -0
  47. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx/utils.py +0 -0
  48. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx.egg-info/dependency_links.txt +0 -0
  49. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx.egg-info/entry_points.txt +0 -0
  50. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/csv2ofx.egg-info/top_level.txt +0 -0
  51. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/amazon.ofx +0 -0
  52. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/creditunion.qif +0 -0
  53. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/default.ofx +0 -0
  54. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/default.qif +0 -0
  55. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/default_w_splits.ofx +0 -0
  56. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/default_w_splits.qif +0 -0
  57. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/gls.ofx +0 -0
  58. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/ingesp.ofx +0 -0
  59. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/mint.ofx +0 -0
  60. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/mint.qif +0 -0
  61. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/mint_alt.qif +0 -0
  62. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/mint_extra.qif +0 -0
  63. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/n26.ofx +0 -0
  64. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/outbank.ofx +0 -0
  65. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/payoneer.ofx +0 -0
  66. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/pcmastercard.ofx +0 -0
  67. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case1.ofx +0 -0
  68. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case2.ofx +0 -0
  69. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case3.ofx +0 -0
  70. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case4.ofx +0 -0
  71. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case5.ofx +0 -0
  72. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case6.ofx +0 -0
  73. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-baltest-case7.ofx +0 -0
  74. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking-msmoney.ofx +0 -0
  75. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/schwab-checking.ofx +0 -0
  76. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/stripe-all.ofx +0 -0
  77. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/stripe-all.qif +0 -0
  78. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/stripe-default.ofx +0 -0
  79. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/stripe-default.qif +0 -0
  80. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/ubs-ch-fr.qif +0 -0
  81. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/converted/xero.qif +0 -0
  82. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/example/investment_example.qif +0 -0
  83. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/example/transaction_example.ofx +0 -0
  84. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/example/transfer_example.ofx +0 -0
  85. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/amazon.csv +0 -0
  86. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/capitalone.csv +0 -0
  87. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/creditunion.csv +0 -0
  88. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/default.csv +0 -0
  89. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/gls.csv +0 -0
  90. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/ingesp.csv +0 -0
  91. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/mint.csv +0 -0
  92. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/mint_extra.csv +0 -0
  93. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/mint_headerless.csv +0 -0
  94. /csv2ofx-0.34.0/data/test/n26.csv → /csv2ofx-0.34.1/data/test/n26-fr.csv +0 -0
  95. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/outbank.csv +0 -0
  96. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/payoneer.csv +0 -0
  97. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/pcmastercard.csv +0 -0
  98. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case1.csv +0 -0
  99. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case2.csv +0 -0
  100. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case3.csv +0 -0
  101. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case4.csv +0 -0
  102. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case5.csv +0 -0
  103. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case6.csv +0 -0
  104. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking-baltest-case7.csv +0 -0
  105. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/schwab-checking.csv +0 -0
  106. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/stripe-all.csv +0 -0
  107. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/stripe-default.csv +0 -0
  108. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/ubs-ch-fr_trimmed.csv +0 -0
  109. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/data/test/xero.csv +0 -0
  110. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/OFX 2.1.1.pdf +0 -0
  111. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/OFXAudit.xls +0 -0
  112. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/OFX_Message_Support.doc +0 -0
  113. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification.html +0 -0
  114. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/a.html +0 -0
  115. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/a_002.html +0 -0
  116. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/a_003.html +0 -0
  117. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/a_004.html +0 -0
  118. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/a_005.html +0 -0
  119. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/bootstrap.js +0 -0
  120. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/jquery.js +0 -0
  121. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/QIF Specification_files/sitecss.css +0 -0
  122. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/docs/qif-file-format.txt +0 -0
  123. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/helpers/check-stage +0 -0
  124. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/helpers/clean +0 -0
  125. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/helpers/srcdist +0 -0
  126. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/helpers/wheel +0 -0
  127. {csv2ofx-0.34.0 → csv2ofx-0.34.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv2ofx
3
- Version: 0.34.0
3
+ Version: 0.34.1
4
4
  Summary: converts a csv file of transactions to an ofx or qif file
5
5
  Author-email: Reuben Cummings <reubano@gmail.com>
6
6
  Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
@@ -24,6 +24,8 @@ Provides-Extra: test
24
24
  Requires-Dist: pytest; extra == "test"
25
25
  Requires-Dist: pytest-enabler; extra == "test"
26
26
  Requires-Dist: pytest-ruff; extra == "test"
27
+ Requires-Dist: freezegun; extra == "test"
28
+ Requires-Dist: pytest-lazy-fixtures; extra == "test"
27
29
  Dynamic: license-file
28
30
 
29
31
  # csv2ofx
@@ -17,6 +17,9 @@ Attributes:
17
17
  """
18
18
 
19
19
  import itertools as it
20
+ import os.path
21
+ import pathlib
22
+ import sys
20
23
  import time
21
24
  import traceback
22
25
  from argparse import ArgumentParser, RawTextHelpFormatter
@@ -24,10 +27,8 @@ from datetime import datetime as dt
24
27
  from importlib import import_module, util
25
28
  from math import inf
26
29
  from operator import itemgetter
27
- from os import path as p
28
30
  from pkgutil import iter_modules
29
31
  from pprint import pprint
30
- from sys import exit, stdin, stdout
31
32
 
32
33
  try:
33
34
  FileNotFoundError
@@ -55,6 +56,23 @@ MAPPINGS = import_module("csv2ofx.mappings")
55
56
  MODULES = tuple(itemgetter(1)(m) for m in iter_modules(MAPPINGS.__path__))
56
57
 
57
58
 
59
+ def load_package_module(name):
60
+ return import_module(f"csv2ofx.mappings.{name}")
61
+
62
+
63
+ def load_custom_module(filepath: str):
64
+ """
65
+ >>> mod = load_custom_module("csv2ofx/mappings/amazon.py")
66
+ >>> mod.__name__
67
+ 'amazon'
68
+ """
69
+ path = pathlib.Path(filepath)
70
+ spec = util.spec_from_file_location(path.stem, path)
71
+ module = util.module_from_spec(spec)
72
+ spec.loader.exec_module(module)
73
+ return module
74
+
75
+
58
76
  parser.add_argument(
59
77
  dest="source", nargs="?", help="the source csv file (default: stdin)"
60
78
  )
@@ -101,7 +119,11 @@ parser.add_argument(
101
119
  choices=MODULES,
102
120
  )
103
121
  parser.add_argument(
104
- "-x", "--custom", metavar="FILE_PATH", help="path to a custom mapping file"
122
+ "-x",
123
+ "--custom",
124
+ metavar="FILE_PATH",
125
+ help="path to a custom mapping file",
126
+ type=load_custom_module,
105
127
  )
106
128
  parser.add_argument(
107
129
  "-c",
@@ -194,34 +216,29 @@ parser.add_argument(
194
216
  "-v", "--verbose", help="verbose output", action="store_true", default=False
195
217
  )
196
218
 
197
- args = parser.parse_args() # pylint: disable=C0103
198
219
 
220
+ def _time_from_file(path):
221
+ return os.path.getmtime(path)
199
222
 
200
- def run(): # noqa: C901
223
+
224
+ def run(args=None): # noqa: C901
201
225
  """Parses the CLI options and runs the main program"""
226
+ args = parser.parse_args(args)
202
227
  if args.debug:
203
228
  pprint(dict(args._get_kwargs())) # pylint: disable=W0212
204
- exit(0)
229
+ sys.exit(0)
205
230
 
206
231
  if args.version:
207
232
  from . import __version__ as version
208
233
 
209
234
  print(f"v{version}")
210
- exit(0)
235
+ sys.exit(0)
211
236
 
212
237
  if args.list_mappings:
213
238
  print(", ".join(MODULES))
214
- exit(0)
215
-
216
- if args.custom:
217
- name = p.splitext(p.split(args.custom)[1])[0]
218
- spec = util.spec_from_file_location(name, args.custom)
219
- module = util.module_from_spec(spec)
220
- spec.loader.exec_module(module)
221
- else:
222
- module = import_module(f"csv2ofx.mappings.{args.mapping}")
239
+ sys.exit(0)
223
240
 
224
- mapping = module.mapping
241
+ mapping = (args.custom or load_package_module(args.mapping)).mapping
225
242
 
226
243
  okwargs = {
227
244
  "def_type": args.account_type or "Bank" if args.qif else "CHECKING",
@@ -232,7 +249,7 @@ def run(): # noqa: C901
232
249
 
233
250
  cont = QIF(mapping, **okwargs) if args.qif else OFX(mapping, **okwargs)
234
251
  source = (
235
- builtins.open(args.source, encoding=args.encoding) if args.source else stdin
252
+ builtins.open(args.source, encoding=args.encoding) if args.source else sys.stdin
236
253
  )
237
254
 
238
255
  ckwargs = {
@@ -256,7 +273,7 @@ def run(): # noqa: C901
256
273
  server_date = parse(args.server_date, dayfirst=args.dayfirst)
257
274
  else:
258
275
  try:
259
- mtime = p.getmtime(source.name)
276
+ mtime = _time_from_file(source.name)
260
277
  except (AttributeError, FileNotFoundError):
261
278
  mtime = time.time()
262
279
 
@@ -272,11 +289,13 @@ def run(): # noqa: C901
272
289
  "encoding": args.encoding,
273
290
  }
274
291
  except Exception as err: # pylint: disable=broad-except
275
- source.close()
276
- exit(err)
292
+ source.close() if args.source else None
293
+ sys.exit(err)
277
294
 
278
295
  dest = (
279
- builtins.open(args.dest, "w", encoding=args.encoding) if args.dest else stdout
296
+ builtins.open(args.dest, "w", encoding=args.encoding)
297
+ if args.dest
298
+ else sys.stdout
280
299
  )
281
300
 
282
301
  try:
@@ -302,9 +321,9 @@ def run(): # noqa: C901
302
321
  else:
303
322
  msg = 0 if res else "No data to write. Check `start` and `end` options."
304
323
  finally:
305
- exit(msg)
306
324
  source.close() if args.source else None
307
325
  dest.close() if args.dest else None
326
+ sys.exit(msg)
308
327
 
309
328
 
310
329
  if __name__ == "__main__":
@@ -17,7 +17,7 @@ Attributes:
17
17
  ENCODING (str): Default file encoding.
18
18
  """
19
19
 
20
- from datetime import datetime as dt
20
+ import datetime
21
21
 
22
22
  from meza.fntools import chunk, xmlize
23
23
  from meza.process import group
@@ -75,7 +75,7 @@ class OFX(Content):
75
75
  (str): the OFX content
76
76
 
77
77
  Examples:
78
- >>> kwargs = {'date': dt(2012, 1, 15)}
78
+ >>> kwargs = {'date': datetime.datetime(2012, 1, 15)}
79
79
  >>> header = 'DATA:OFXSGMLENCODING:UTF-8<OFX><SIGNONMSGSRSV1>\
80
80
  <SONRS><STATUS><CODE>0</CODE><SEVERITY>INFO</SEVERITY></STATUS><DTSERVER>\
81
81
  20120115000000</DTSERVER><LANGUAGE>ENG</LANGUAGE></SONRS></SIGNONMSGSRSV1>\
@@ -101,7 +101,9 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
101
101
  kwargs.setdefault("language", "ENG")
102
102
 
103
103
  # yyyymmddhhmmss
104
- time_stamp = kwargs.get("date", dt.now()).strftime("%Y%m%d%H%M%S")
104
+ time_stamp = kwargs.get("date", datetime.datetime.now()).strftime(
105
+ "%Y%m%d%H%M%S"
106
+ )
105
107
 
106
108
  content = ""
107
109
  if self.ms_money:
@@ -150,7 +152,6 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
150
152
  (dict): the OFX transaction data
151
153
 
152
154
  Examples:
153
- >>> import datetime
154
155
  >>> from csv2ofx.mappings.mint import mapping
155
156
  >>> from decimal import Decimal
156
157
  >>> trxn = {
@@ -169,7 +170,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
169
170
  ... 'memo': 'description notes',
170
171
  ... 'id': 'ee86450a47899254e2faa82dca3c2cf2',
171
172
  ... 'split_account': 'Checking', 'action': '', 'payee': 'payee',
172
- ... 'date': dt(2010, 6, 12, 0, 0), 'category': '',
173
+ ... 'date': datetime.datetime(2010, 6, 12, 0, 0), 'category': '',
173
174
  ... 'bank_id': 'e268443e43d93dab7ebef303bbe9642f',
174
175
  ... 'price': Decimal('0'), 'symbol': '', 'check_num': None,
175
176
  ... 'inv_split_account': None, 'x_action': '', 'type': 'DEBIT',
@@ -226,7 +227,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
226
227
  (str): the OFX content
227
228
 
228
229
  Examples:
229
- >>> kwargs = {'start': dt(2012, 1, 1), 'end': dt(2012, 2, 1)}
230
+ >>> kwargs = {'start': datetime.datetime(2012, 1, 1), 'end': datetime.datetime(2012, 2, 1)}
230
231
  >>> akwargs = {'currency': 'USD', 'bank_id': 1, 'account_id': 1, \
231
232
  'account_type': 'CHECKING'}
232
233
  >>> start = '<STMTRS><CURDEF>USD</CURDEF><BANKACCTFROM><BANKID>1\
@@ -286,7 +287,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
286
287
  (str): the OFX content
287
288
 
288
289
  Examples:
289
- >>> kwargs = {'date': dt(2012, 1, 15), 'type': 'DEBIT', \
290
+ >>> kwargs = {'date': datetime.datetime(2012, 1, 15), 'type': 'DEBIT', \
290
291
  'amount': 100, 'id': 1, 'check_num': 1, 'payee': 'payee', 'memo': 'memo'}
291
292
  >>> trxn = '<STMTTRN><TRNTYPE>DEBIT</TRNTYPE><DTPOSTED>\
292
293
  20120115000000</DTPOSTED><TRNAMT>100.00</TRNAMT><FITID>1</FITID><CHECKNUM>1\
@@ -329,7 +330,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
329
330
  (str): the OFX content
330
331
 
331
332
  Examples:
332
- >>> kwargs = {'balance': 150, 'date': dt(2012, 1, 15)}
333
+ >>> kwargs = {'balance': 150, 'date': datetime.datetime(2012, 1, 15)}
333
334
  >>> end = '</BANKTRANLIST><LEDGERBAL><BALAMT>150.00</BALAMT>\
334
335
  <DTASOF>20120115000000</DTASOF></LEDGERBAL></STMTRS>'
335
336
  >>> result = OFX().account_end(**kwargs)
@@ -408,7 +409,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
408
409
  (str): the start of an OFX transfer
409
410
 
410
411
  Examples:
411
- >>> kwargs = {'currency': 'USD', 'date': dt(2012, 1, 15), \
412
+ >>> kwargs = {'currency': 'USD', 'date': datetime.datetime(2012, 1, 15), \
412
413
  'bank_id': 1, 'account_id': 1, 'account_type': 'CHECKING', 'amount': 100, \
413
414
  'id': 'jbaevf'}
414
415
  >>> trxn = '<INTRARS><CURDEF>USD</CURDEF><SRVRTID>jbaevf</SRVRTID>\
@@ -508,7 +509,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
508
509
 
509
510
  Examples:
510
511
  >>> end = '</XFERINFO><DTPOSTED>20120115000000</DTPOSTED></INTRARS>'
511
- >>> result = OFX().transfer_end(dt(2012, 1, 15))
512
+ >>> result = OFX().transfer_end(datetime.datetime(2012, 1, 15))
512
513
  >>> end == result.replace('\\n', '').replace('\\t', '')
513
514
  True
514
515
  """
@@ -529,12 +530,12 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
529
530
 
530
531
  Examples:
531
532
  >>> ft = '</BANKTRANLIST></STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>'
532
- >>> result = OFX().footer(date=dt(2012, 1, 15))
533
+ >>> result = OFX().footer(date=datetime.datetime(2012, 1, 15))
533
534
  >>> result = list(result)[0]
534
535
  >>> ft == result.replace('\\n', '').replace('\\t', '')
535
536
  True
536
537
  """
537
- kwargs.setdefault("date", dt.now())
538
+ kwargs.setdefault("date", datetime.datetime.now())
538
539
 
539
540
  if self.is_split:
540
541
  content = self.transfer_end(**kwargs)
@@ -617,21 +618,21 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
617
618
 
618
619
  Examples:
619
620
  >>> ofx = OFX()
620
- >>> trxn1 = { 'date': dt(2010, 6, 12, 0, 0) }
621
- >>> trxn2 = { 'date': dt(2010, 6, 12, 0, 0) }
622
- >>> trxn3 = { 'date': dt(2010, 6, 13, 0, 0) }
621
+ >>> trxn1 = { 'date': datetime.datetime(2010, 6, 12, 0, 0) }
622
+ >>> trxn2 = { 'date': datetime.datetime(2010, 6, 12, 0, 0) }
623
+ >>> trxn3 = { 'date': datetime.datetime(2010, 6, 13, 0, 0) }
623
624
  >>> ofx.update_latest_trxn(trxn1)
624
- >>> ofx.latest_trxn['date'] == dt(2010, 6, 12, 0, 0)
625
+ >>> ofx.latest_trxn['date'] == datetime.datetime(2010, 6, 12, 0, 0)
625
626
  True
626
627
  >>> ofx.latest_date_count
627
628
  1
628
629
  >>> ofx.update_latest_trxn(trxn2)
629
- >>> ofx.latest_trxn['date'] == dt(2010, 6, 12, 0, 0)
630
+ >>> ofx.latest_trxn['date'] == datetime.datetime(2010, 6, 12, 0, 0)
630
631
  True
631
632
  >>> ofx.latest_date_count
632
633
  2
633
634
  >>> ofx.update_latest_trxn(trxn3)
634
- >>> ofx.latest_trxn['date'] == dt(2010, 6, 13, 0, 0)
635
+ >>> ofx.latest_trxn['date'] == datetime.datetime(2010, 6, 13, 0, 0)
635
636
  True
636
637
  >>> ofx.latest_date_count
637
638
  1
@@ -653,10 +654,10 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
653
654
 
654
655
  Examples:
655
656
  >>> ofx = OFX()
656
- >>> trxn1 = { 'date': dt(2010, 6, 12, 0, 0) }
657
- >>> trxn2 = { 'date': dt(2010, 6, 12, 0, 0) }
658
- >>> trxn3 = { 'date': dt(2010, 6, 13, 0, 0) }
659
- >>> trxn4 = { 'date': dt(2010, 6, 11, 0, 0) }
657
+ >>> trxn1 = { 'date': datetime.datetime(2010, 6, 12, 0, 0) }
658
+ >>> trxn2 = { 'date': datetime.datetime(2010, 6, 12, 0, 0) }
659
+ >>> trxn3 = { 'date': datetime.datetime(2010, 6, 13, 0, 0) }
660
+ >>> trxn4 = { 'date': datetime.datetime(2010, 6, 11, 0, 0) }
660
661
  >>> ofx.update_last_trxn(trxn1)
661
662
  >>> ofx.check_date_order(trxn2)
662
663
  >>> ofx.dates_ascending
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv2ofx
3
- Version: 0.34.0
3
+ Version: 0.34.1
4
4
  Summary: converts a csv file of transactions to an ofx or qif file
5
5
  Author-email: Reuben Cummings <reubano@gmail.com>
6
6
  Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
@@ -24,6 +24,8 @@ Provides-Extra: test
24
24
  Requires-Dist: pytest; extra == "test"
25
25
  Requires-Dist: pytest-enabler; extra == "test"
26
26
  Requires-Dist: pytest-ruff; extra == "test"
27
+ Requires-Dist: freezegun; extra == "test"
28
+ Requires-Dist: pytest-lazy-fixtures; extra == "test"
27
29
  Dynamic: license-file
28
30
 
29
31
  # csv2ofx
@@ -89,7 +89,7 @@ data/test/ingesp.csv
89
89
  data/test/mint.csv
90
90
  data/test/mint_extra.csv
91
91
  data/test/mint_headerless.csv
92
- data/test/n26.csv
92
+ data/test/n26-fr.csv
93
93
  data/test/outbank.csv
94
94
  data/test/payoneer.csv
95
95
  data/test/pcmastercard.csv
@@ -6,3 +6,5 @@ meza<0.48.0,>=0.47.0
6
6
  pytest
7
7
  pytest-enabler
8
8
  pytest-ruff
9
+ freezegun
10
+ pytest-lazy-fixtures
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "csv2ofx"
7
- version = "0.34.0"
7
+ version = "0.34.1"
8
8
  description = "converts a csv file of transactions to an ofx or qif file"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -42,6 +42,8 @@ test = [
42
42
  "pytest",
43
43
  "pytest-enabler",
44
44
  "pytest-ruff",
45
+ "freezegun",
46
+ "pytest-lazy-fixtures",
45
47
  ]
46
48
 
47
49
  [tool.setuptools]
@@ -2,10 +2,13 @@ import itertools
2
2
  import pathlib
3
3
  import shlex
4
4
  import subprocess
5
+ import time
5
6
 
7
+ import freezegun
6
8
  import pytest
9
+ from pytest_lazy_fixtures import lf
7
10
 
8
- SERVER_DATE = "-D 20161031112908"
11
+ import csv2ofx.main
9
12
 
10
13
  samples = [
11
14
  (["-oq"], "default.csv", "default.qif"),
@@ -15,29 +18,29 @@ samples = [
15
18
  (["-oq", "-m mint_extra"], "mint_extra.csv", "mint_extra.qif"),
16
19
  (["-oq", "-m mint_headerless"], "mint_headerless.csv", "mint.qif"),
17
20
  (["-oqs20150613", "-e20150614", "-m mint"], "mint.csv", "mint_alt.qif"),
18
- (["-oe 20150908", SERVER_DATE], "default.csv", "default.ofx"),
19
- (["-o", "-m split_account", SERVER_DATE], "default.csv", "default_w_splits.ofx"),
20
- (["-o", "-m mint", SERVER_DATE], "mint.csv", "mint.ofx"),
21
+ (["-oe 20150908"], "default.csv", "default.ofx"),
22
+ (["-o", "-m split_account"], "default.csv", "default_w_splits.ofx"),
23
+ (["-o", "-m mint"], "mint.csv", "mint.ofx"),
21
24
  (["-oq", "-m creditunion"], "creditunion.csv", "creditunion.qif"),
22
25
  (
23
- ["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
26
+ ["-o", "-m stripe", "-e", "20210505"],
24
27
  "stripe-default.csv",
25
28
  "stripe-default.ofx",
26
29
  ),
27
30
  (
28
- ["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
31
+ ["-o", "-m stripe", "-e", "20210505"],
29
32
  "stripe-all.csv",
30
33
  "stripe-all.ofx",
31
34
  ),
32
35
  (["-oq", "-m stripe"], "stripe-default.csv", "stripe-default.qif"),
33
36
  (["-oq", "-m stripe"], "stripe-all.csv", "stripe-all.qif"),
34
37
  (
35
- ["-E windows-1252", "-m gls", SERVER_DATE, "-e 20171111", "-o"],
38
+ ["-E windows-1252", "-m gls", "-e 20171111", "-o"],
36
39
  "gls.csv",
37
40
  "gls.ofx",
38
41
  ),
39
42
  (
40
- ["-o", "-m pcmastercard", "-e 20190120", SERVER_DATE],
43
+ ["-o", "-m pcmastercard", "-e 20190120"],
41
44
  "pcmastercard.csv",
42
45
  "pcmastercard.ofx",
43
46
  ),
@@ -47,79 +50,80 @@ samples = [
47
50
  # ["-oq", "-m ubs-ch-fr"], "ubs-ch-fr_trimmed.csv", "ubs-ch-fr.qif"
48
51
  # ),
49
52
  (
50
- ["-o", "-m ingesp", "-e 20221231", SERVER_DATE],
53
+ ["-o", "-m ingesp", "-e 20221231"],
51
54
  "ingesp.csv",
52
55
  "ingesp.ofx",
53
56
  ),
54
57
  (
55
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
58
+ ["-o", "-m schwabchecking", "-e 20220905"],
56
59
  "schwab-checking.csv",
57
60
  "schwab-checking.ofx",
58
61
  ),
59
62
  (
60
- ["-o", "-M", "-m schwabchecking", "-e 20220905", SERVER_DATE],
63
+ ["-o", "-M", "-m schwabchecking", "-e 20220905"],
61
64
  "schwab-checking.csv",
62
65
  "schwab-checking-msmoney.ofx",
63
66
  ),
64
67
  (
65
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
68
+ ["-o", "-m schwabchecking", "-e 20220905"],
66
69
  "schwab-checking-baltest-case1.csv",
67
70
  "schwab-checking-baltest-case1.ofx",
68
71
  ),
69
72
  (
70
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
73
+ ["-o", "-m schwabchecking", "-e 20220905"],
71
74
  "schwab-checking-baltest-case2.csv",
72
75
  "schwab-checking-baltest-case2.ofx",
73
76
  ),
74
77
  (
75
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
78
+ ["-o", "-m schwabchecking", "-e 20220905"],
76
79
  "schwab-checking-baltest-case3.csv",
77
80
  "schwab-checking-baltest-case3.ofx",
78
81
  ),
79
82
  (
80
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
83
+ ["-o", "-m schwabchecking", "-e 20220905"],
81
84
  "schwab-checking-baltest-case4.csv",
82
85
  "schwab-checking-baltest-case4.ofx",
83
86
  ),
84
87
  (
85
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
88
+ ["-o", "-m schwabchecking", "-e 20220905"],
86
89
  "schwab-checking-baltest-case5.csv",
87
90
  "schwab-checking-baltest-case5.ofx",
88
91
  ),
89
92
  (
90
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
93
+ ["-o", "-m schwabchecking", "-e 20220905"],
91
94
  "schwab-checking-baltest-case6.csv",
92
95
  "schwab-checking-baltest-case6.ofx",
93
96
  ),
94
97
  (
95
- ["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
98
+ ["-o", "-m schwabchecking", "-e 20220905"],
96
99
  "schwab-checking-baltest-case7.csv",
97
100
  "schwab-checking-baltest-case7.ofx",
98
101
  ),
99
102
  (
100
- ["-o", "-m amazon", "-e 20230604", SERVER_DATE],
101
- "amazon.csv",
103
+ ["-o", "-m amazon", "-e 20230604"],
104
+ lf("amazon_inputs"),
102
105
  "amazon.ofx",
103
106
  ),
104
107
  (
105
- ["-o", "-m payoneer", "-e 20220905", SERVER_DATE],
108
+ ["-o", "-m payoneer", "-e 20220905"],
106
109
  "payoneer.csv",
107
110
  "payoneer.ofx",
108
111
  ),
109
112
  (
110
- ['-m', 'n26', SERVER_DATE],
111
- 'n26.csv',
113
+ ['-m', 'n26'],
114
+ 'n26-fr.csv',
112
115
  'n26.ofx',
113
116
  ),
114
117
  ]
115
118
 
116
119
 
117
- @pytest.fixture(autouse=True)
118
- def amazon_env(monkeypatch):
120
+ @pytest.fixture
121
+ def amazon_inputs(monkeypatch):
119
122
  # for Amazon import; excludes transaction 3/3
120
123
  monkeypatch.setenv("AMAZON_EXCLUDE_CARDS", "9876")
121
124
  # clear the purchases account if set
122
125
  monkeypatch.delenv("AMAZON_PURCHASES_ACCOUNT", raising=False)
126
+ return "amazon.csv"
123
127
 
124
128
 
125
129
  data = pathlib.Path('data')
@@ -130,16 +134,18 @@ def flatten_opts(opts):
130
134
 
131
135
 
132
136
  @pytest.mark.parametrize(['opts', 'in_filename', 'out_filename'], samples)
133
- def test_sample(opts, in_filename, out_filename):
137
+ @freezegun.freeze_time("2016-10-31 11:29:08")
138
+ def test_sample(opts, in_filename, out_filename, capsys, monkeypatch):
139
+ monkeypatch.setattr(csv2ofx.main, '_time_from_file', lambda path: time.time())
134
140
  arguments = [str(data / 'test' / in_filename)]
135
141
  command = list(itertools.chain(['csv2ofx'], flatten_opts(opts), arguments))
136
- proc = subprocess.run(
137
- command, capture_output=True, text=True, encoding='utf-8', check=True
138
- )
139
- output = proc.stdout
142
+ with pytest.raises(SystemExit) as exc:
143
+ csv2ofx.main.run(command[1:])
144
+ # Success - exit code 0
145
+ assert exc.value.code == 0
140
146
 
141
147
  expected = data.joinpath("converted", out_filename).read_text(encoding='utf-8')
142
- assert output == expected, (
148
+ assert capsys.readouterr().out == expected, (
143
149
  f"Unexpected output from {subprocess.list2cmdline(command)}"
144
150
  )
145
151
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes