summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-12-29 09:27:49 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-01-01 08:37:13 +0100
commitb5e3853e9dc4f755072e3e8d20c7c84d30104ad1 (patch)
tree97754576c6e049d32c1bf78f7a5a8e783348b0b2
parent763942d8c7243db84afd59ba13f2e396ceb93b07 (diff)
pyolian: make the library and the generator importable from another folder
-rw-r--r--.gitignore2
-rw-r--r--src/scripts/pyolian/__init__.py0
-rw-r--r--src/scripts/pyolian/eolian.py14
-rwxr-xr-xsrc/scripts/pyolian/generator.py22
4 files changed, 32 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 76dd79784d..195dfdc64c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,8 @@ tags
41*.eot.cs 41*.eot.cs
42*.eo.lua 42*.eo.lua
43*.luac 43*.luac
44*.pyc
45__pycache__
44.dir-locals.el 46.dir-locals.el
45/efl-*-doc.tar.bz2 47/efl-*-doc.tar.bz2
46/ar-lib 48/ar-lib
diff --git a/src/scripts/pyolian/__init__.py b/src/scripts/pyolian/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/scripts/pyolian/__init__.py
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 5baa2d3d7d..8a3d21f00a 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -14,11 +14,23 @@ You can directly use the python API provided here if you need direct access
14to eolian, or we suggest to look at the template-based generator.py if you just 14to eolian, or we suggest to look at the template-based generator.py if you just
15need to generate some sort of text files out of the eolian database. 15need to generate some sort of text files out of the eolian database.
16 16
17To use this library from outside this directory, you need to hack sys.path in
18a way that this folder will be available on PYTHON_PATH, fe:
19
20 pyolian_path = os.path.join(EFL_ROOT_PATH, 'src', 'scripts')
21 sys.path.insert(0, pyolian_path)
22 from pyolian import eolian
23 from pyolian.generator import Template
24
17""" 25"""
18from enum import IntEnum 26from enum import IntEnum
19from ctypes import cast, byref, c_char_p, c_void_p 27from ctypes import cast, byref, c_char_p, c_void_p
20 28
21from eolian_lib import lib 29try:
30 from .eolian_lib import lib
31except ImportError:
32 from eolian_lib import lib
33
22 34
23 35
24### Eolian Enums ############################################################ 36### Eolian Enums ############################################################
diff --git a/src/scripts/pyolian/generator.py b/src/scripts/pyolian/generator.py
index b1e9bca786..5fad2484a5 100755
--- a/src/scripts/pyolian/generator.py
+++ b/src/scripts/pyolian/generator.py
@@ -15,9 +15,6 @@ For example (from this source folder):
15 15
16...of course you can pass any other class or namespace to the example above. 16...of course you can pass any other class or namespace to the example above.
17 17
18You can also import this module and use the provided Template class if you
19are more confortable from within python.
20
21The generator is based on the great pyratemp engine (THANKS!), you can find 18The generator is based on the great pyratemp engine (THANKS!), you can find
22the full template syntax at: www.simple-is-better.org/template/pyratemp.html 19the full template syntax at: www.simple-is-better.org/template/pyratemp.html
23 20
@@ -30,12 +27,27 @@ Just keep in mind the syntax is a bit different in this implementation:
30 comment_start = "#!" 27 comment_start = "#!"
31 comment_end = "!#" 28 comment_end = "!#"
32 29
30
31You can also import this module and use the provided Template class if you
32are more confortable from within python. To import from outside this directory
33you need to hack sys.path in a way that this folder will be available on
34PYTHON_PATH, fe:
35
36 pyolian_path = os.path.join(EFL_ROOT_PATH, 'src', 'scripts')
37 sys.path.insert(0, pyolian_path)
38 from pyolian.generator import Template
39
40
33""" 41"""
34import os 42import os
35import datetime 43import datetime
36 44
37import eolian 45try:
38import pyratemp 46 from . import eolian
47 from . import pyratemp
48except ImportError:
49 import eolian
50 import pyratemp
39 51
40 52
41# logging utils 53# logging utils