jwork no celery-mode, should resolve wildcard imports
This commit is contained in:
parent
aa38487f9f
commit
ebd9ad0460
28
botanjs/dummy.py
Normal file
28
botanjs/dummy.py
Normal file
@ -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
|
@ -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 )
|
||||
|
@ -1,18 +1,28 @@
|
||||
#!/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" ):
|
||||
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:
|
||||
|
||||
@app.task()
|
||||
|
Loading…
Reference in New Issue
Block a user