def workspace(root_path): u''' 源库所在工作区 ''' if StaticPackage.get_root(root_path): ui.msg(Workspace.get_workspace(root_path)) else: ui.msg(u'不是一个源库') return 1
def publish(path, publish_path = None, force = False, rebuild = False): u'''将整个发布库进行编译''' do_link = False # 指定了第二个参数,则path一定是一个源库,第二个参数则是发布库,并自动进行link if publish_path: root_path = StaticPackage.get_root(path) path = publish_path # 发布整个库 do_link = True # 没有指定第二个参数,则path一定是一个发布库 else: publish_path, root_path = StaticPackage.get_roots(path) if not publish_path: ui.msg(u'No publish path.') else: package = StaticPackage(root_path, publish_path = publish_path) if not package.publish_path: ui.msg(u'No publish path.') else: ui.msg(u'publish to %s' % (path,) + (' with rebuild' if rebuild else '')) if rebuild: # 遍历磁盘目录,慢 all_files = package.get_publish_files() else: # 只搜索合并索引,快 all_files = package.listener.get_files() for filename in all_files: compile(filename, package = package, force = force, no_build_files = True) buildfiles(package = package) if do_link: package.link()
def incs(filename, all = False, reverse = False): u''' 某文件所有依赖的文件 ''' filename = os.path.realpath(filename) root_path = StaticPackage.get_root(filename) package = StaticPackage(root_path) filetype = os.path.splitext(filename)[1] if reverse: if filetype == '.css': ui.error(u'Not support yet, sorry.') return 1 else: files = package.get_included(filename, all = all) else: files = package.get_relation_files(filename, all = all) for file in files: ui.msg(file)
def libs(root_path, show_url = False, all = False, reverse = False): u''' 库的相关依赖库 ''' root_path = StaticPackage.get_root(root_path) if not root_path: ui.error(u'不是源库') return 1 package = StaticPackage(root_path) # 这个库没有设置url,不可能被别的库依赖 if not package.url: ui.error(u'no url') return 1 # 显示依赖自己的 if reverse: try: libs = package.get_reverse_libs(all = all) except PackageNotFoundException, e: ui.error(u'%s package not found' % e.url) return 1
def source(publish_path): u''' 映射的源库路径 ''' if StaticPackage.get_publish(publish_path): StaticPackage.get_root(publish_path) else: ui.error(u'不是一个发布库')
def root(root_path): u''' 源库的根路径 ''' ui.msg(StaticPackage.get_root(root_path))