Commit Graph

200 Commits

Author SHA1 Message Date
c-holtermann
0434acbe10 reformat two python example scripts with black
use black python code formatter on latex_invoices.py and gncinvoice_jinja.py
2020-06-21 16:23:32 +02:00
c-holtermann
485d8a65b0 decorate Session.begin with default mode argument 2020-06-21 16:23:32 +02:00
c-holtermann
44e61f4df2 enable Session.__init__() to be provided with existing instance or book 2020-06-21 16:23:32 +02:00
c-holtermann
5833c5afcb add unittests for function_class
add tests for some existing function_class functionality.
Add tests for the keyword argument changes.
2020-06-21 16:23:32 +02:00
c-holtermann
17d606e1f8 enable keyword arguments for default_arguments_decorator
default_arguments_decorator until now only allows positional
argument defaults. This adds keyword defaults. The keywords
can be mapped to the positional arguments by optional argument
kargs_pos so interactions between keyword and positional arg
defaults can raise a TypeError. Some more information in
the docstring is included. In addition the docstring of
the wrapped function will be modified to contain information
about the defaults.
2020-06-21 16:23:32 +02:00
c-holtermann
c222503f42 add method decorate_method to function_class.py
ClassFromFunctions.decorate_method() allows to provide positional
and keyword arguments for the decorator call besides the wrapped
method.
2020-06-21 16:23:32 +02:00
c-holtermann
ee77b713c2 update example scripts to SessionOpenMode 2020-06-21 16:23:32 +02:00
c-holtermann
b073dbc5c3 allow keyword arguments for function_class.py
allow keyword arguments for function_class methods
and functions. process_dict_convert_to_instance() is added to
mimic the behavior of the process_list_convert_to_instance()
Derived methods in gnucash_core.py like raise_backend_errors_after_call
get modified to accept being called with keyword args.
Also adds some docstrings.
2020-06-21 16:23:32 +02:00
c-holtermann
4e280b9593 adapt to use of sessionOpenMode in qof_session_begin 2020-06-20 13:40:11 +02:00
c-holtermann
48072f5a4c make SessionOpenMode enum available for python 2020-06-20 11:02:13 +02:00
c-holtermann
ee3342d2b4 introduce python submodule deprecation
the deprecation submodule will house content related to deprecation.
That is general convenience function and functions related to specific
deprecation issues. The latter starts with decorator functions to bridge
the change in qof_session_begin argument change to SessionOpenMode.
2020-06-20 10:40:54 +02:00
John Ralls
6a1cb5eecd Replace the three bool parameters to qof_session_begin to an enum.
For clarity. In so doing found the backend behavior a bit inconsistent
so it's modified to do what the enum values indicate.

In the course of changing the various calls I found some implementation
errors in the back end and corrected them.
2020-06-04 14:07:28 -07:00
c-holtermann
0ac59b18b7 make logging accessible from python modules 2020-06-02 21:28:03 +02:00
c-holtermann
b13f40aeaf remove translation test 2020-05-28 20:55:15 +02:00
c-holtermann
e1701fbdd6 locale is not needed anymore (debug) 2020-05-28 20:42:27 +02:00
c-holtermann
9e678a421e remove debug stuff 2020-05-28 20:31:16 +02:00
c-holtermann
7bf38ef837 test info 2020-05-28 20:29:33 +02:00
c-holtermann
ca21f32249 remove global gettext import 2020-05-28 20:21:31 +02:00
c-holtermann
efe9b4b606 remove debug info 2020-05-28 20:19:39 +02:00
c-holtermann
f788e59318 remove debug stuff (temporarily) 2020-05-28 18:51:01 +02:00
c-holtermann
fc87e275fa further debugging 2020-05-28 18:51:01 +02:00
c-holtermann
8d429d8295 further debugging 2020-05-28 18:51:01 +02:00
c-holtermann
2c09fe4f44 debug on travis 2020-05-28 18:51:01 +02:00
c-holtermann
694e5a26ff add test for gettext 2020-05-28 18:50:55 +02:00
c-holtermann
31d2b3cb44 install gettext 2020-05-28 18:41:34 +02:00
c-holtermann
41dc6ddbe2 implement gettext localization for python
make gnc_path_get_localedir() and GETTEXT_PACKAGE available for python
to access locales. Import gettext module to provide _ as translator
method. Provide null _-method returning english text in case of missing gettext.
Make a lot of messages translatable by adding _-method. Include python
files to create .pot-files.
2020-05-28 18:41:34 +02:00
John Ralls
320db3270b Remove duplicate decl. 2020-05-08 15:59:41 -07:00
John Ralls
8ff5af4c19 Decouple QofBook creation from QofSession.
So that we don't create two books when loading a session.
Step 1 to not having a dirty book when we think we should have no
book at all.
2020-05-08 15:59:41 -07:00
Christopher Lam
14ea5d9751 Merge branch 'maint' 2020-05-04 23:31:21 +08:00
John Ralls
6a3fabc30d Fix test failure for timezones west of the prime meridian.
The previous fix didn't calculate the comparison time correctly and
ended up in the wrong day because the GMT time is before the local time.

In the course of checking the corner-case timezones (Midway and
Kiritimati) I found an error in the GncDateTime calculation of the
neutral time, so fixed that too.
2020-05-02 15:35:13 -07:00
John Ralls
b4177bc60a Fix transaction post_date being set to midnight local.
Reported for Invoices on gnucash-user. Checked all other uses of
xaccTransSetPostDateSecs(), fixed the ones that weren't passing an
already normalized time64. For Invoices change the post_date to also be
normalized so that it stays the same as the transaction post_date. That
also protects it from the displayed date changing depending on timezone.

The python binding invoice post_time test had to be changed to match.
2020-04-30 12:09:22 -07:00
John Ralls
de9ee8dede Merge branch 'maint' 2020-04-25 15:45:59 -07:00
Geert Janssens
bbeb9a2b62 Drop all gnc-module dependencies and includes from compilation units that no longer use it
This also drops the python wrapper for gnc-module. As for the guile wrappers,
python should use other means of loading our shared libraries.

This commit required a few tweaks to the dependency chain as some units
inherited dependency information from gnc-module's public dependency
interface.
2020-04-24 22:16:24 +02:00
c-holtermann
0553576c81 restructure info so that python help will display it 2020-04-20 16:07:50 +02:00
c-holtermann
f6cb803192 app_utils needs to be imported to module gnucash to be accessible 2020-04-20 15:23:14 +02:00
Geert Janssens
0cfb40efeb CMake - use configure_file instead of file(COPY ) wherever possible
file(COPY ) will only trigger when the destination file doesn't exist yet.
It won't retrigger on source file changes.
configure_file on the other hand will. To avoid unwanted substitution
attempts this can be invoked with the COPYONLY keyword.
Disadvantage of configure_file is that it will only take one
input file where file(COPY ) can operate on a list of files.
As such the configure_file statement has to be wrapped in a foreach.

A few uses of file(COPY ) can't be replaced as they are setting
file permissions. And the one in make_dist has been kept as that
always operates on an empty directory, hence copying is guaranteed.

The former will monitor the file for updates and copy it again
the latter will only copy the file if it doesn't exist in the destination yet
2020-04-19 21:23:22 +02:00
John Ralls
3ca8fa1229 Merge branch 'maint' 2020-04-13 11:27:14 -07:00
John Ralls
e1b0140357 Fix failed build of python tests and failed test in 3.10 tarball. 2020-04-12 13:43:00 -07:00
John Ralls
882fd22ca1 Merge Christoph Holtermann's 'python-app-utils' into maint. 2020-04-06 12:17:03 -07:00
John Ralls
fdfaca5575 Merge Christoph Holtermann's 'python-session-instance-constructor' into maint. 2020-04-06 12:05:21 -07:00
c-holtermann
e2c37359ef high level python wrappers for app-utils 2020-04-06 07:22:06 +02:00
c-holtermann
4dcdec664a remove whitespace in parentheses (PEP 8) 2020-04-06 07:03:40 +02:00
c-holtermann
43cebedd3d tests for session 2020-04-06 07:03:40 +02:00
c-holtermann
daff201ffb don't allow instance=None for wrapper objects 2020-04-06 07:03:03 +02:00
c-holtermann
0da6b851b0 add instance argument to Session constructor
if Session is used only as a wrapper for an existing session instance
its necessary to be able to pass this instance as an argument
2020-04-02 18:59:16 +02:00
andygoblins
08af4ce9bd context manager examples 2020-02-29 17:46:01 -06:00
andygoblins
f1f450cedc make Session a context manager 2020-02-29 17:46:01 -06:00
andygoblins
4502afad4f fix __eq__ in Split and Transaction
Compare guids with .Equal() when comparing Split and Transaction instances.
2020-02-29 17:44:55 -06:00
Christopher Lam
62c2203d40 Merge branch 'maint' 2020-01-30 20:30:04 +08:00
loftx
7cd2495674 Add Invoice.Unpost() to Python Bindings 2020-01-20 20:26:53 +01:00
Geert Janssens
f52c581ddc Merge branch 'dropgml' 2019-12-07 09:15:48 +01:00
Geert Janssens
d52aa0a0dd app-utils - remove gnc-module boilerplate
app-utils now is an ordinery shared library

A few bits worth mentioning:
1. it's not guile-free just yet, so instead of a gnc_module_load
   your code may have to call scm_c_use_module("gnucash app-utils");
   to expose the scm side of the app-utils api. This call has been
   added to gnucash-bin.c for example
2. while lots of noise in this commit is to rename from gncmodule-app-utils
   to gnc-app-utils, I'll point out the library has also been moved from
   <libdir>/gnucash to <libdir>. This required changes in app-util's
   CMakeLists.txt file for the install side and in the top level
   CMakeLists.txt file for the build directory structure.
3. The C side link module test has been removed as linking an ordinary
   shared library should be considered well tested by the compiler devs.
   The scheme side module load test has been slightly tweaked to no longer
   try to use gnc:module-load, but instead now checks whether the app-utils
   api is properly exposed to scheme after loading it via use-modules.
4. Dropped a completely obsolete README file.
2019-12-06 20:38:21 +01:00
Geert Janssens
4c77f7670e engine - remove gncmod boilerplate
engine is now an ordinary shared library

This requires a few more places to run gnc_engine_init as
this is no longer done as part of module loading.
2019-12-06 20:38:21 +01:00
Geert Janssens
1c7f835f47 engine - move guile code to bindings/guile
This commit tries to do the minimum necessary to move the guile bits from engine
to bindings/guile. As engine is a very central piece in the software, this unfortunately
still touches many other source files:

- A few helper objects have been squashed together:
  * engine-helpers-guile.[ch] (of which the c part is extracted from engine-helpers.c)
  * gncBusGuile.[ch]
  * gnc-hooks-scm.[ch]
- The initialization function of gncmod-engine no longer initializes the scm bits.
  Any scm code that wants to interact with the engine code now has to load
  the (gnucash engine) scm module, or sometimes (gnucash business-core).
  The bulk of changes in this commit actually is updating all the scm consumers to do so.
- scm-scm target has been removed. Instead (gnucash utilities) is part
  of scm-engine. A few dependency graphs have been updated for this.

More refinements will be in followup commits.
2019-12-06 19:59:11 +01:00
Geert Janssens
a6b7eecd81 core-utils - make the swig generated source file dependent on the core-utils headers
That should trigger a regeneration of these swig sources if
any of the header files change.
This is done via a small macro that can be reused for other wrappers as well.

Note
cmake 3.15 introduces a 'FILTER' generator expression
that might allow us to do something like the following:
$<FILTER:$<TARGET_PROPERTY:baselib,SOURCES>,INCLUDE,"*.h[pp]?$">
I toyed briefly with that idea but it currently has two issues:
1. 3.15 is newer than our current minimum cmake requirement, so we can't
   depend in that feature yet.
2. the sources are relative to *their* source directory, which
   is different from the one in which the wrappers are generated
   So they should still be properly transformed into absolute paths
2019-12-06 19:59:11 +01:00
Geert Janssens
a1898daf6c core-utils - move python wrapper code to bindings/python
This makes libgnucash/core-utils completely guile and python free.
2019-12-06 19:59:11 +01:00
Geert Janssens
33e1ff645c Allow to pass include directories to the add_swig_xyz commands
This will be needed when the wrappers no longer live in
the same directory as the objects they are wrapping.
2019-12-06 19:59:11 +01:00
Geert Janssens
df1f033f41 bindings-python - drop references to gnucash-env
We no longer ship a gnucash-env script, directly use python(3) instead
2019-11-30 13:20:08 +01:00
Andrey Legayev
34c14b44a9
Remove not needed semicolons in Python bindings 2019-11-29 18:32:50 +02:00
luz.paz
65bb60d621 Fix typos for gnuchash/ doc/ bindings/ and misc.
Typos found via `codespell -q 3 -D ~/Projects/codespell/codespell_lib/data/dictionary.txt -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,cas,dragable,gae,iff,iif,mut,nd,numer,startd,stoll`
2019-09-13 20:26:03 -04:00
Geert Janssens
15a35e6a3b Housekeeping - replace plenty of http links with https
There are more, but these are most common ones.
There are also a number of urls that don't behave well when https, so those are skipped
At some point I have also started marking non-working URLs as [DEAD LINK], though
that's not a full coverage.
2019-06-06 15:52:30 +02:00
Mike Evans
29416292a9 Remove FIX ME
Since it works fine and I can't remember why I put it in.
2019-05-01 11:46:42 +01:00
John Ralls
fc355958b8 Merge Christoph Holtermann's 'PR-python2to3-rest-api' into maint. 2019-04-14 14:27:53 -07:00
John Ralls
b2f25408d7 Merge Christoff Holtermann's 'PR-python-time64-modifications' into maint 2019-04-14 14:26:35 -07:00
John Ralls
8823f7283f Merge Christoph Holtermann's 'PR-python2to3' into maint. 2019-04-14 14:24:16 -07:00
c-holtermann
0c02866964 PyDate_Check works for date and datetime 2019-04-06 17:13:41 +02:00
c-holtermann
18a2688419 typo 2019-04-06 16:17:58 +02:00
c-holtermann
db9e98a812 also allow datetime.date
Initialisation of some business objects has been done with
datetime.date.today() and it is also mentioned as a possibility
in the source doc. So leave it possible.
2019-04-06 16:10:04 +02:00
c-holtermann
3884e6abf5 unobfuscate get_date method name 2019-04-06 16:09:01 +02:00
c-holtermann
8ba5e552d9 return None object if return value is FALSE 2019-04-06 14:50:29 +02:00
c-holtermann
dafdd702e6 additional author 2019-04-06 14:12:06 +02:00
c-holtermann
79decfb754 deal with functions returning values through arguments 2019-04-06 14:11:55 +02:00
c-holtermann
445ff7e6c9 check for argument type. Also allow int. 2019-04-06 14:11:05 +02:00
c-holtermann
c779bcb72f GetOwner may return project instead of owner 2019-04-04 17:56:42 +02:00
c-holtermann
6925ee3115 be prepared for GetDateDue returning null 2019-04-04 17:56:31 +02:00
c-holtermann
876079f8d2 remove TS suffix 2019-04-04 17:56:24 +02:00
c-holtermann
6eae440534 GetDate return unserializable datetime object 2019-04-04 17:56:16 +02:00
c-holtermann
b73be1b523 GetInvTaxTable returns unserializable object 2019-04-04 17:56:06 +02:00
c-holtermann
b06801185c shebang should be specific to python version (PEP394)
preferred form is #!/usr/bin/env python3 as gnucash now only works with
python3
2019-04-04 17:48:42 +02:00
c-holtermann
e7d940ac3f iteritems removed in python3 2019-04-04 17:48:10 +02:00
c-holtermann
77727ffc49 python3 does not return list of keys 2019-04-04 17:47:52 +02:00
c-holtermann
64a01f3027 python3 - 'as' needed in exceptions instead of comma 2019-04-04 17:47:34 +02:00
c-holtermann
0068475bb1 xrange has been dropped in python3 2019-04-04 17:47:14 +02:00
c-holtermann
298797a9be fix due to different invoice date handling 2019-04-04 11:53:40 +02:00
Christoph Holtermann
206ed63233 typo 2019-04-04 11:53:23 +02:00
Christoph Holtermann
247d04a544 make executable, remove double -o 2019-04-04 11:52:44 +02:00
Christoph Holtermann
1184e92687 2to3 2019-04-04 11:52:13 +02:00
Christoph Holtermann
002595f4cc add options iOP 2019-04-04 11:51:00 +02:00
Christoph Holtermann
61f7613b8d fix for python3 2019-04-04 11:49:20 +02:00
Rob Reid
9be545f5ce Fixes for new 64-bit time setter/getters 2019-01-06 22:05:43 +08:00
John Ralls
b8574a004a Merge Christoff Holterman's 'PR-Python-GetBalTaxValues' into maint. 2018-12-24 13:53:22 -08:00
Frank Oltmanns
5675dad2f3 Update query for get_all_customers
Use same time of query in get_all_customers as in get_all_invoices
2018-12-24 13:42:22 -08:00
Christoph Holtermann
ff660a873e Revert "Question about GncMonetary class instead of tuple"
This reverts commit 8fe0b14213.
Question has been discussed in pull request.
2018-12-04 12:17:56 +01:00
Christoph Holtermann
8fe0b14213 Question about GncMonetary class instead of tuple 2018-12-04 12:14:23 +01:00
Christoph Holtermann
b431d471e0 decorate monetary list to access GncCommodity and GncNumeric 2018-12-04 12:14:23 +01:00
Christoph Holtermann
929a3bcd9e pass additional args and document function 2018-12-04 12:14:22 +01:00
Frank H. Ellenberger
0467dd0b92 Fix several URLs in documentation parts
We have no longer svn, but 2 doxygen branches.
I don't remember, when Mailman moved from www to lists.
2018-11-03 10:15:19 +01:00
John Ralls
d9ed847595 Merge Christoph Holterman's 'PR-python2to3fixes' into maint. 2018-10-16 09:37:25 -07:00
Tom Lofts
820cd842f1 Bug 796893 - invoice.GetDatePosted() and other date related...
functions returns strange values for uninitalised dates.

Convert time64 equal to INT64_MAX to Python's None value.
2018-10-06 14:59:52 -07:00
Mahmoud Yaser
3e014f189f
Update change_tax_code.py 2018-09-26 08:21:17 +02:00