def get_extjs_sourceroot_from_appname(appname): appdir = get_staticdir_from_appname(appname) if appname == 'extjs4': return join(appdir, 'src') if exists(join(appdir, 'app')): return join(appdir, 'app') else: return appdir
def find_javascriptfiles(): jsfiles = [] extjssources = abspath(join(get_staticdir_from_appname('extjshelpers'), 'extjs')) jasminesources = abspath(join(get_staticdir_from_appname('jsapp'), 'jasmine')) for appdir, module, appname in get_installed_apps(): for root, dirs, files in walk(join(appdir, 'static')): if extjssources in abspath(root): # Skip extjs continue if jasminesources in abspath(root): # Skip jasmine sources continue if 'jasminespecs' in root: # Skip jasmine tests continue for filename in files: if filename in ('all-classes.js', 'app-all.js'): # Skip compiled apps continue if filename.endswith('.js'): filepath = join(root, filename) jsfiles.append(filepath) return jsfiles
def handle(self, *args, **options): setup_logging(get_verbosity(options)) if len(args) != 1: raise CommandError('Requires an <appname>.') appname = args[0] appdir = get_staticdir_from_appname(appname) appfile = join(appdir, 'app.js') jsfile = AppFile(appfile, appname) #jsfile.prettyprint() jsfiles = jsfile.get_all_jsfiles() ordered = orderJsFiles(jsfiles) outfile = join(appdir, 'app-all.js') content = '\n\n'.join([j.filecontent for j in ordered]) content += '\n\n' + jsfile.filecontent open(outfile, 'wb').write(content)
def create_jsfile_for_extjsclass(self, classname): """ ``create_jsfile_for_class``, but with all of the hacks required to handle finding stuff in the extjs sources. """ if classname in self.EXTJS_ALTERNATE_NAMES: return self.create_jsfile_for_extjsclass(self.EXTJS_ALTERNATE_NAMES[classname]) from os import sep appdir = get_staticdir_from_appname('extjs4') relativepath = sep.join(classname.split('.')[1:]) + '.js' app_path = None for dirname in self.EXTJS_CLASSPATH: path = join(appdir, dirname, relativepath) if exists(path): app_path = path break if not app_path: raise ValueError('Could not find any file for: {0}'.format(classname)) try: return JsFile(classname, app_path) except ValueError: return SimpleJsFile(classname, app_path)
def test_get_staticdir_from_appname(self): staticdir = get_staticdir_from_appname('test', [(join('path', 'to'), None, 'something'), (join('another', 'dir'), None, 'test')]) self.assertEqual(staticdir, join('another', 'dir', 'static', 'test')) self.assertRaises(ValueError, get_staticdir_from_appname, 'test', [])
def test_get_staticdir_from_appname(self): staticdir = get_staticdir_from_appname( 'test', [(join('path', 'to'), None, 'something'), (join('another', 'dir'), None, 'test')]) self.assertEquals(staticdir, join('another', 'dir', 'static', 'test')) self.assertRaises(ValueError, get_staticdir_from_appname, 'test', [])