anzeige der gefundenen werte bei testabfrage, liste von vordefinierten abfragen begonnen

This commit is contained in:
Frederik Jaeckel 2022-11-22 09:37:24 +01:00
parent b57c69abf0
commit ffba5c2a45
6 changed files with 110 additions and 4 deletions

View file

@ -210,6 +210,10 @@ msgctxt "view:investment.source:"
msgid "How to" msgid "How to"
msgstr "So funktionierts" msgstr "So funktionierts"
msgctxt "view:investment.source:"
msgid "Values detected during the query"
msgstr "bei der Abfrage erkannte Werte"
msgctxt "view:investment.source:" msgctxt "view:investment.source:"
msgid "Configure a source for receiving course data here. The source is queried with the parameters according to schedule." msgid "Configure a source for receiving course data here. The source is queried with the parameters according to schedule."
msgstr "Konfigurieren Sie hier eine Quelle für den Empfang von Kursdaten. Die Quelle wird mit den Paramtern nach Zeitplan abgefragt." msgstr "Konfigurieren Sie hier eine Quelle für den Empfang von Kursdaten. Die Quelle wird mit den Paramtern nach Zeitplan abgefragt."
@ -326,6 +330,30 @@ msgctxt "help:investment.source,rgxidtype:"
msgid "Type of identifier used to validate the result." msgid "Type of identifier used to validate the result."
msgstr "Typ des Bezeichners zur Validierung des Ergebnisses." msgstr "Typ des Bezeichners zur Validierung des Ergebnisses."
msgctxt "field:investment.source,fnddate:"
msgid "Date"
msgstr "Datum"
msgctxt "help:investment.source,fnddate:"
msgid "Date found during test query."
msgstr "Bei der Testabfrage gefundenes Datum."
msgctxt "field:investment.source,fndrate:"
msgid "Rate"
msgstr "Kurs"
msgctxt "help:investment.source,fndrate:"
msgid "Rate found during test query."
msgstr "Bei der Testabfrage gefundener Kurs."
msgctxt "field:investment.source,fndident:"
msgid "Identifier"
msgstr "Bezeichner"
msgctxt "help:investment.source,fndident:"
msgid "Identifier found during test query."
msgstr "Bei der Testabfrage gefundener Bezeichner."
################### ###################
# investment.rate # # investment.rate #

View file

@ -178,6 +178,10 @@ msgctxt "view:investment.source:"
msgid "How to" msgid "How to"
msgstr "How to" msgstr "How to"
msgctxt "view:investment.source:"
msgid "Values detected during the query"
msgstr "Values detected during the query"
msgctxt "view:investment.source:" msgctxt "view:investment.source:"
msgid "Configure a source for receiving course data here. The source is queried with the parameters according to schedule." msgid "Configure a source for receiving course data here. The source is queried with the parameters according to schedule."
msgstr "Configure a source for receiving course data here. The source is queried with the parameters according to schedule." msgstr "Configure a source for receiving course data here. The source is queried with the parameters according to schedule."
@ -294,6 +298,30 @@ msgctxt "help:investment.source,rgxidtype:"
msgid "Type of identifier used to validate the result." msgid "Type of identifier used to validate the result."
msgstr "Type of identifier used to validate the result." msgstr "Type of identifier used to validate the result."
msgctxt "field:investment.source,fnddate:"
msgid "Date"
msgstr "Date"
msgctxt "help:investment.source,fnddate:"
msgid "Date found during test query."
msgstr "Date found during test query."
msgctxt "field:investment.source,fndrate:"
msgid "Rate"
msgstr "Rate"
msgctxt "help:investment.source,fndrate:"
msgid "Rate found during test query."
msgstr "Rate found during test query."
msgctxt "field:investment.source,fndident:"
msgid "Identifier"
msgstr "Identifier"
msgctxt "help:investment.source,fndident:"
msgid "Identifier found during test query."
msgstr "Identifier found during test query."
msgctxt "model:investment.rate,name:" msgctxt "model:investment.rate,name:"
msgid "Rate" msgid "Rate"
msgstr "Rate" msgstr "Rate"

View file

@ -32,7 +32,8 @@ sel_rgxdatefmt = [
('%Y-%m-%d', 'yyyy-mm-dd'), ('%Y-%m-%d', 'yyyy-mm-dd'),
] ]
fields_check = ['url', 'nsin', 'isin', 'symbol', 'text', 'http_state'] fields_check = ['url', 'nsin', 'isin', 'symbol', 'text', 'http_state', \
'fnddate', 'fndrate', 'fndident']
class OnlineSource(ModelSQL, ModelView): class OnlineSource(ModelSQL, ModelView):
@ -74,6 +75,15 @@ class OnlineSource(ModelSQL, ModelView):
readonly=True), 'on_change_with_http_state') readonly=True), 'on_change_with_http_state')
text = fields.Function(fields.Text(string='Result', text = fields.Function(fields.Text(string='Result',
readonly=True), 'on_change_with_text') readonly=True), 'on_change_with_text')
fnddate = fields.Function(fields.Date(string='Date', readonly=True,
help='Date found during test query.'),
'on_change_with_fnddate')
fndrate = fields.Function(fields.Numeric(string='Rate', readonly=True,
help='Rate found during test query.', digits=(16,4)),
'on_change_with_fndrate')
fndident = fields.Function(fields.Char(string='Identifier', readonly=True,
help='Identifier found during test query.'),
'on_change_with_fndident')
@classmethod @classmethod
def default_url(cls): def default_url(cls):
@ -135,6 +145,15 @@ class OnlineSource(ModelSQL, ModelView):
""" """
self.call_online_source() self.call_online_source()
def on_change_with_fnddate(self, name=None):
return None
def on_change_with_fndrate(self, name=None):
return None
def on_change_with_fndident(self, name=None):
return ''
def on_change_with_http_state(self, name=True): def on_change_with_http_state(self, name=True):
return '' return ''
@ -182,6 +201,9 @@ class OnlineSource(ModelSQL, ModelView):
) )
self.text = result.get('text', None) self.text = result.get('text', None)
self.http_state = result.get('http_state', None) self.http_state = result.get('http_state', None)
self.fnddate = result.get('date', None)
self.fndrate = result.get('rate', None)
self.fndident = result.get('code', None)
def get_url_with_parameter(self, isin=None, nsin=None, symbol=None): def get_url_with_parameter(self, isin=None, nsin=None, symbol=None):
""" generate url """ generate url
@ -276,9 +298,7 @@ class OnlineSource(ModelSQL, ModelView):
result['rate'] = updtsource.get_regex_result(html, 'rgxrate') result['rate'] = updtsource.get_regex_result(html, 'rgxrate')
result['date'] = updtsource.get_regex_result(html, 'rgxdate') result['date'] = updtsource.get_regex_result(html, 'rgxdate')
result['code'] = updtsource.get_regex_result(html, 'rgxcode') result['code'] = updtsource.get_regex_result(html, 'rgxident')
print('\n## result:', result)
else : else :
logger.error('read_from_website: %(code)s, url: %(url)s, redirects: [%(redirects)s]' % { logger.error('read_from_website: %(code)s, url: %(url)s, redirects: [%(redirects)s]' % {
'code': res1.status_code, 'code': res1.status_code,

21
sources_def.xml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-module from m-ds for Tryton.
The COPYRIGHT file at the top level of this repository contains the
full copyright notices and license terms. -->
<tryton>
<data>
<record model="investment.source" id="web_finanzen_net">
<field name="name">www.finanzen.net - ETF</field>
<field name="url">https://www.finanzen.net/etf/${isin}/tgt</field>
<field name="nohtml" eval="True"/>
<field name="rgxdate">\nKurszeit (\d+\.\d+\.\d+) \d{2}:\d{2}:\d{2}.*\n</field>
<field name="rgxdatefmt">%d.%m.%Y</field>
<field name="rgxrate">\nKurs (\d+,\d+) EUR.*\n</field>
<field name="rgxdecimal">,</field>
<field name="rgxident">WKN:.* ISIN: ([A-Z,0-9]+).*</field>
<field name="rgxidtype">isin</field>
</record>
</data>
</tryton>

View file

@ -12,6 +12,7 @@ xml:
group.xml group.xml
asset.xml asset.xml
onlinesource.xml onlinesource.xml
sources_def.xml
update_wiz.xml update_wiz.xml
rate.xml rate.xml
menu.xml menu.xml

View file

@ -43,6 +43,14 @@ full copyright notices and license terms. -->
<label name="symbol"/> <label name="symbol"/>
<field name="symbol"/> <field name="symbol"/>
<separator id="sepfnd" colspan="6" string="Values detected during the query"/>
<label name="fnddate"/>
<field name="fnddate"/>
<label name="fndrate"/>
<field name="fndrate"/>
<label name="fndident"/>
<field name="fndident"/>
<separator name="text" colspan="6" string="Result"/> <separator name="text" colspan="6" string="Result"/>
<field name="text" colspan="6" xexpand="1"/> <field name="text" colspan="6" xexpand="1"/>
</page> </page>