-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up plugin methods #347
Conversation
Add NO_LEADING_ZEROS_SERIAL config Some contests discourage sending leading zeros.
Saw it already and review is on my schedule. Need some more time to think about. Hope to find time on weekend. |
Drop 'nr_qsos' variable, use length of 'qsos_array' instead
As an start some unsorted items and questions I stumbled about while reading the code:
If we leave aside the plugin specific code (will look it up later) it looks quite good so far. Handling and writing should be easy (if you are fluent in regular expressions). There should be some documentation (maybe a README howto use the functionality) before merging into the master branch. Are some of the 'FIXME' statements critical and have to be fixed before merging? Anyway good work. Looks promising. |
Another point:
So we need some kind of versioning for it. Otherwise someone with an old TLF version may be trying to use rule scripts written for newer plugin version. In the script there should be something like 'Required_Version' or similar. |
Thanks for the review!
It tries to load the file
It's standard python, for Debian
Yes, it can be dropped from py file.
See the initial comment: The plan is to be able to pass information on the actual rule-set like category (in-state/ex-state), etc.
Leftover, dropped.
This is done in TLF internally, if you mean the housekeeping of mults. It is however assumed that plugin provides a legit mult value, it is used as-is.
I was focusing on the good case, some error handling branches are left open. They are not critical.
One option would be to let |
Will be added to the manual as a last step of this PR. |
Thanks for the explanations.
Ok, So try to find a plugin and if not found fall back to conventional behavior.
And as far as I can see regex module is part of the python standard distribution.
At the moment we are at 3.10 here. 3.11 will be our standard version early next year.
Ok. So a simple string to pass and interpretation lies in the responsibility of the plugin.
Ok. I see. So nothing should be needed. Fine.
Or the other way round. Make the init function in rules.py mandatory and provide it with the support version nr in the 'tlf' module. The let it check itself and return true or false depending upon that number being sufficient. Only question: Do we want to use the normal TLF version number or do we need an additional API version? I think normal version number should fit. We should also think which information about the qso may be used by newer 'creative' contest rules. I remember such things as being allowed to work a station in different time slots of the whole contest more than once. So it may be appropriated to add some more information to the qso structure , e.g. the time and date. But again, that may be add in a later version using the mechanism already in place. |
Re API version check: we could use TLF version number. It has the advantage that it's more transparent to the end user ("This plugin requires TLF 2.1 but you are running 1.9~git ..."). The check is better done in TLF core as comparing two version numbers is somewhat involved (we don't want each plugin author to come up with their own check method) and this way we also can give a consistent error message. |
Consistent error message can be done in TLF also if we use true/false return. but I agree it would be good to have a common check function. So the init function should return the minimal version number (as string?).
Why 1.6? The next number would be 1.5. If we integrate the plugin code before next release it would be fine. We should only guarantee that 1.5~git is scored as below 1.5. Or do I miss a point here? |
I mixed up the 1.6, so all is fine. 1.5~git is in fact pre-1.5 and thus treated the same as 1.5. Yes,
It's also fine to return Changed |
requires Python 3.9
Add California QSO party rules - Sending leading zeros is discouraged in CQP - Add custom cabrillo qso format for cqp
* in addition migrate NO_LEADING_ZEROS_SERIAL to LEADING_ZEROS_SERIAL
The basic idea is to return the contents of the |
From http://www.country-files.com/cty-dat-format/ and the code in dxcc.c you can see that dxcc_data represents the major country information which eventually gets overridden (with more precise information) from the following prefix entries (in prefix_data). E.g. long and lat in dxcc_data are for center of country and the same in prefix_data are specific for the prefix area. Similar for timezone, itu / cq zone and others. The prefix entries all link back to the dxcc country info via the 'dxcc_ctynr' struct member. So maybe the prefix data are most relevant for the plugin. They should be completed by missing information from the dxcc_data entry. As far as I can see the dxcc entry give the following additional info:
|
Added Example: the result of Also exposed |
Moved Hamlib log level setting before initialization to avoid output like
|
Looks good and should serve all our purposes. |
How do I compile it?
I enabled python plugin with |
The configure call is correct. Here is the output I get
Did you try it on a fresh clone? |
It turned out I needed to install python-config that matches my python version 3.10. For some reason my debian doesn't have python3.10-config, but it allowed me to change python-config to use python 3.10 version instead of 2.7. Also I would suggest to document that python plugin file name is derived from the name of the CONTEST in the logcfg.dat I initially thought that the name is the same as the rules files. I took the example from hadx. In hadx it probaby works because hadx doesn't have CONTEST field. |
I also ran into that issue with |
Just tested this feature in NA qso party. Works like a charm. Can't wait to have it in the master branch! When it's merged I'll have naqp rules for you. |
Updated man page for Fixed HA-DX: score for own country has to be specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR (because the mentioned line was added in a previous comment), but for general review: the band
member of the qso object is always 0, seems Tlf never fill it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two notes for this PR, let me know if I can help anything.
If there are no conceptual problems or other major issues then my preference would be to merge this into master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Just go on with the merge Zoli. I think all critical problems got sorted out back in january. |
Add Python plugin support (#347) Some functions can be overridden by contest specific plugin methods. --------- Co-authored-by: Victor Denisov <[email protected]> Co-authored-by: Thomas Beierlein <[email protected]> Co-authored-by: Thomas Beierlein <[email protected]> Co-authored-by: Jonathan Bastien-Filiatrault <[email protected]>
Merged dev_plugin into master. |
As the base code got improved in the last year or so, it's time to somewhat clean-up and stabilize plugin code. If there are no objections then it could be even merged into master.
Current API has following methods:
init(param)
: called once upon start of TLF. It shall initialize or load any internal data. Currentlyparam
is a fixed empty string. The plan is to be able to pass information on the actual rule-set like category (in-state/ex-state), etc.setup()
: called when log is loaded or re-loaded. It shall reset any internal scoring-related data.score(qso)
: evaluates QSO and returns an integer score. Available QSO fields currently are:band
,call
,mode
,exchange
.check_exchange(qso)
: check QSO and can return a dictionary containingmult1_value
(for multiplier counting) and/ornormalized_exchange
(to pretty-print the exchange). All return values are optional.All methods are optional.
The API can be refined and extended in the future but as it stands it gives a stable base to start with. There also still open points in the code, but they are mostly related to error handling.
Contests like UBA #346 will require the special handling that can be added via a plugin.