-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode
More file actions
52 lines (43 loc) · 1.46 KB
/
Copy pathcode
File metadata and controls
52 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdfe="http://redfoot.net/3.0/rdf#"
xmlns:code="http://redfoot.net/3.0/code#"
>
<rdfs:Class rdf:ID="Code">
<rdfs:label>Code</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
</rdfs:Class>
<rdfs:Class rdf:ID="Module">
<rdfs:label>Python Module</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:subClassOf rdf:resource="#Code"/>
<code:constructor>
<code:Python rdf:ID="PythonModuleConstructor">
<code:python rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
<![CDATA[
# TODO check_cache bit
import sys, types
_logger = redfoot.getLogger(__uri__)
module_name = this.__uri__
_logger.debug("creating module: %s" % this.__uri__)
safe_module_name = "__uri___%s" % hash(this.__uri__)
module = types.ModuleType(safe_module_name)
module.__name__ = module_name
module.__file__ = this.__uri__
module.__ispkg__ = 0
#sys.modules[module_name] = module
module.__dict__.update(redfoot.globals)
this.execute(this.__uri__, context=module.__dict__)
for item in dir(module):
this.__setattr__(item, module.__dict__.get(item))
# TODO: Do we need/want to do the following instead:
# this = module
]]>
</code:python>
</code:Python>
</code:constructor>
</rdfs:Class>
</rdf:RDF>