I have a python code that manages some parameters using some variable
rules that may change from day to day. I'd like that the code will
self-modify according to rules parsed from a xml file:
example:
<rules>
<rule01>
<if>
<or>
<lessthan par_1="glicemyA tMorning" par_2="80"/>
<lessthan par_1="glicemyA tNight" par_2="80"/>
<and>
<greaterthan par_1="glicemyA tMorning" par_2="0"/>
<or>
<equalto par_1="urine" par_2="0"/>
<equalto par_1="urine" par_2="+/-"/>
<equalto par_1="urine" par_2="+"/>
</or>
</and>
</or>
</if>
<then>
<sendmessage>So mething is wrong!</sendmessage>
</then>
</rule01>
<rule02... </rule02>
<rule03... </rule03>
</rules>
Due to the fact that rules may change, I have to manage the python
program, parsing the whole xml file, and self-modify the python code
according to these variable rules.
How can I do? 3 1272
jonny wrote:
I have a python code that manages some parameters using some variable
rules that may change from day to day. I'd like that the code will
self-modify according to rules parsed from a xml file:
example:
<rules>
<rule01>
<if>
<or>
<lessthan par_1="glicemyA tMorning" par_2="80"/>
<lessthan par_1="glicemyA tNight" par_2="80"/>
<and>
<greaterthan par_1="glicemyA tMorning" par_2="0"/>
<or>
<equalto par_1="urine" par_2="0"/>
<equalto par_1="urine" par_2="+/-"/>
<equalto par_1="urine" par_2="+"/>
</or>
</and>
</or>
</if>
<then>
<sendmessage>So mething is wrong!</sendmessage>
</then>
</rule01>
<rule02... </rule02>
<rule03... </rule03>
</rules>
Due to the fact that rules may change, I have to manage the python
program, parsing the whole xml file, and self-modify the python code
according to these variable rules.
How can I do?
So, essentially you are creating a dynamic language? But you already have
one - python!
Who's responsible for creating these rules, and what do they allow to be
done? Because I'd rather use python snippets to define them, that you
compile using the exec-function.
If you insist on using XML, use some module like lxml to parse and create
your own language constructs.
Just a note: the use of "par_X" as attributes is unfortunate, to say the
least. It doesn't allow for easy argument swapping, can cause troubles
because you delete one attribute and miss renaming the others, and in
general it's not good design to have arbitrary numbers of parameters.
Instead, you better go with a nested param-tag.
Diez
On Mon, 24 Sep 2007 13:42:05 +0200, Diez B. Roggisch wrote:
jonny wrote:
><rules> <rule01> <if> <or> <lessthan par_1="glicemyA tMorning" par_2="80"/> <lessthan par_1="glicemyA tNight" par_2="80"/> <and> <greaterthan par_1="glicemyA tMorning" par_2="0"/> <or> <equalto par_1="urine" par_2="0"/> <equalto par_1="urine" par_2="+/-"/> <equalto par_1="urine" par_2="+"/> </or> </and> </or> </if> <then> <sendmessage>So mething is wrong!</sendmessage> </then> </rule01> <rule02... </rule02> <rule03... </rule03> </rules> […]
[…]
Just a note: the use of "par_X" as attributes is unfortunate, to say the
least. It doesn't allow for easy argument swapping, can cause troubles
because you delete one attribute and miss renaming the others, and in
general it's not good design to have arbitrary numbers of parameters.
Quite the same is true for numbers in tag names. If you (the OP) need to
number the rules better use an attribute for the numbers.
Ciao,
Marc 'BlackJack' Rintsch
Marc 'BlackJack' Rintsch wrote:
On Mon, 24 Sep 2007 13:42:05 +0200, Diez B. Roggisch wrote:
>jonny wrote:
>><rules> <rule01> <if> <or> <lessthan par_1="glicemyA tMorning" par_2="80"/> <lessthan par_1="glicemyA tNight" par_2="80"/> <and> <greatertha n par_1="glicemyA tMorning" par_2="0"/> <or> <equalto par_1="urine" par_2="0"/> <equalto par_1="urine" par_2="+/-"/> <equalto par_1="urine" par_2="+"/> </or> </and> </or> </if> <then> <sendmessage>So mething is wrong!</sendmessage> </then> </rule01> <rule02... </rule02> <rule03... </rule03> </rules> […]
[…] Just a note: the use of "par_X" as attributes is unfortunate, to say the least. It doesn't allow for easy argument swapping, can cause troubles because you delete one attribute and miss renaming the others, and in general it's not good design to have arbitrary numbers of parameters.
Quite the same is true for numbers in tag names. If you (the OP) need to
number the rules better use an attribute for the numbers.
I meant of course
<equalto>
<param>0</param>
<param>+</param>
</equalto>
Diez This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Ratliff |
last post by:
I have a few global variables in my app. They are defined in the main
application class file and declared (extern) in a header which can be
included by anyone who would want to use these variables.
Two of the globals are pointers which are initialized at runtime. The others
are classes whose values are initialized in the global space. When I had
just the pointers, I didn't need to include the extern header in the
defining class file. But...
|
by: vcp |
last post by:
<xml newbie>
Hi all,
We are considering using XML to specify rules, policies. This XML file
will be used to generate source code in either managed C++ or C#,
which will be implemention of API to be used by different applications
program (written in .NET language, for this dicussion). You can
contribute your ideas.
|
by: Jason Shohet |
last post by:
I have 6 rules for a given 'time' value.
if (0 < iTime <= .5) {iFee = 17}
else if ( .5 < iTime <= 1) {iFee = 20}
else if...
else if...
yada yada
I don't want to code this in C# within my application, or a web service,
because then I have to recompile everytime a user decides to tweek the rules
|
by: Frosty |
last post by:
Howto make datagrid enforce rules of xml schema?
Created xml schema in the designer. Constraints created there using the following
<xs:simpleType name="zipcode"><xs:restriction base="xs:string"><xs:pattern value="\d{5}" /></xs:restriction></xs:simpleType
Datagrid does not enforce this rule, even though dataGrid1_Validating() is called.
dataset.WriteXml() saves withouth any warning, but
|
by: Charles Krug |
last post by:
List:
I've a module that's not doing what I expect. My guess is that I don't
quite understand the scoping rules the way I should.
I have an object that's costly to create. My thought was to create it
at the module level like this:
# expensive Object Module
| |
by: fctk |
last post by:
source: http://rm-f.net/~orange/devel/specifications/c89-draft.html#3.1.2.2
there are two passages in this paragraph i can't fully understand:
1) "If the declaration of an identifier for an object or a function
contains the storage-class specifier extern , the identifier has the
same linkage as any visible declaration of the identifier with file
scope. If there is no visible declaration with file scope, the
identifier has external...
|
by: John Wright |
last post by:
I am trying to create some custom rules for FxCop and having problems.
1. Is there any good examples of writing custom rules in vb.net?
2. I have created a simple one, including the xml file, but when loaded in
fxCop it says it cannot find the rules.xml file in the manifest. How do I
get it there?
3. Does anyone have any good examples of rules they use?
John Wright
|
by: dennis.sprengers |
last post by:
* I'm trying to work out some rewrite rules that should do the
following:
case 1: a request to mysite.com:
rewrite http://www.mysite.com/files/sheets.ppt
to http://www.mysite.com/sites/default/files/sheets.ppt
case 1 - n: a request to othersite.com:
rewrite http://www.othersite.com/files/sheets.ppt
to http://www.othersite.com/sites/othersite/files/sheets.ppt
|
by: Tim Haughton |
last post by:
Firstly, if there's a better newsgroup to ask this on, feel free to redirect
me.
I have these requirements of WDS for a project:
1) I need to be able to add a new location to the user scope rules for WDS
so that it indexes an application specific folder. This folder, at the
moment, contains only text files.
2) This folder *should not* be included in any of Vista's searches from the
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |