commit ebd9ad04609626c80dfe0d03ec65a1a3f2350922
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2016-03-14T19:01:46Z |
| subject | jwork no celery-mode, should resolve wildcard imports |
commit ebd9ad04609626c80dfe0d03ec65a1a3f2350922
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2016-03-14T19:01:46Z
jwork no celery-mode, should resolve wildcard imports
---
botanjs/dummy.py | 28 ++++++++++++++++++++++++++++
botanjs/service/jclassresv.py | 16 ++++++++++++++++
botanjs/service/jwork.py | 24 +++++++++++++++++-------
3 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/botanjs/dummy.py b/botanjs/dummy.py
new file mode 100644
index 0000000..ce93373
--- /dev/null
+++ b/botanjs/dummy.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+class log:
+ def info( self, *args ):
+ print( *args )
+
+class dummyTask( object ):
+
+ Func = None
+
+ def delay( self, *args ):
+ self.Func( *args )
+
+ def __init__( self, *args ):
+ self.Func = args[0]
+
+ def __call__( self, *args ):
+ pass
+
+class dummyConf:
+ def update( self, BROKER_URL = None ):
+ pass
+
+class app:
+ conf = dummyConf()
+
+ def task():
+ return dummyTask
diff --git a/botanjs/service/jclassresv.py b/botanjs/service/jclassresv.py
index fca9931..33d53e7 100644
--- a/botanjs/service/jclassresv.py
+++ b/botanjs/service/jclassresv.py
@@ -52,6 +52,22 @@ class Resolver:
fx = "/".join( self.EX_CLASS + x for x in lista[:-1] )
+ # resolve wildcard A.B.*
+ if c[-2:] == ".*":
+ elem = self.bMap.findall( ".//" + fx + self.EX_CLASS )
+
+ if elem == None:
+ raise LookupError( "Namespace does not exists or contains no classes: " + c )
+
+ c = c[0:-1]
+ for cl in elem:
+ cl = c + cl.attrib[ "name" ]
+
+ if cl not in self.resolved:
+ self.__resolve( cl, classList )
+
+ return
+
it = lista[-1]
# Test if class
elem = self.bMap.find( ".//" + fx + self.EX_CLASS + it )
diff --git a/botanjs/service/jwork.py b/botanjs/service/jwork.py
index a6e7546..97e4fc9 100644
--- a/botanjs/service/jwork.py
+++ b/botanjs/service/jwork.py
@@ -1,17 +1,27 @@
#!/usr/bin/env python3
import os
-from celery import Celery
-from celery.utils.log import get_task_logger
from botanjs.compressor.closure import Wrapper as ClosureWrapper
from botanjs.compressor.yui import Wrapper as YUIWrapper
from botanjs.classmap import ClassMap
-app = Celery( "botanJWork" )
-log = get_task_logger( __name__ )
+CeleryExists = True
+try:
+ from celery import Celery
+except ImportError:
+ CeleryExists = False
-if os.path.exists( "settings.ini" ):
- from botanjs.config import Config
- app.conf.update( BROKER_URL = Config["BotanJS"]["CeleryBroker"] )
+if CeleryExists:
+ from celery.utils.log import get_task_logger
+ app = Celery( "botanJWork" )
+ log = get_task_logger( __name__ )
+
+ if os.path.exists( "settings.ini" ):
+ from botanjs.config import Config
+ app.conf.update( BROKER_URL = Config["BotanJS"]["CeleryBroker"] )
+
+else:
+ from botanjs.dummy import app
+ from botanjs.dummy import log
class JWork: