From 501762f3b5fa3bfc38be85705e25e8baec1ca8f4 Mon Sep 17 00:00:00 2001 From: cw Date: Wed, 14 May 2014 15:03:32 +0800 Subject: [PATCH] remove post-new.py --- templates/lua-template-runtime/post-new.py | 91 ---------------------- 1 file changed, 91 deletions(-) delete mode 100644 templates/lua-template-runtime/post-new.py diff --git a/templates/lua-template-runtime/post-new.py b/templates/lua-template-runtime/post-new.py deleted file mode 100644 index 9ea2911c34..0000000000 --- a/templates/lua-template-runtime/post-new.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python2.7 -# coding=utf-8 - -from xml.etree import ElementTree -import json -import os -import sys - -def setAndroidOrientation(orientation): - dir_path = os.path.dirname(__file__) - filePath = os.path.join(dir_path,"frameworks/runtime-src/proj.android/AndroidManifest.xml") - try: - androidNS = "http://schemas.android.com/apk/res/android" - ElementTree.register_namespace("android", androidNS) - tree = ElementTree.parse(filePath) - print tree - root = tree.getroot() - #androidNS = root.nsmap["android"] - screenOrientation = "{%s}screenOrientation" %(androidNS) - for element in root.getiterator("activity"): - print element.attrib - if orientation: - element.attrib[screenOrientation] = "landscape" - else: - element.attrib[screenOrientation] = "portrait" - - tree.write(filePath, encoding = "utf-8", xml_declaration = True) - except Exception: - print("parser %s file failure" % filePath) - -def setConfigJson(name,viewWith,viewHeight,orientation): - dir_path = os.path.dirname(__file__) - filePath = os.path.join(dir_path,"res/config.json") - try: - f = open(filePath) - cfg_content = json.load(f) - f.close() - if cfg_content.has_key("init_view"): - if name: - cfg_content["init_view"]["name"] = name - if viewWith: - cfg_content["init_view"]["width"] = viewWith - if viewHeight: - cfg_content["init_view"]["height"] = viewHeight - if orientation: - cfg_content["init_view"]["isLandscape"] = True - else: - cfg_content["init_view"]["isLandscape"] = False - else: - initViewObject={} - if name: - initViewObject["name"] = name - if viewWith: - initViewObject["width"] = viewWith - if viewHeight: - initViewObject["height"] = viewHeight - if orientation: - initViewObject["isLandscape"] = True - else: - initViewObject["isLandscape"] = False - - cfg_content["init_view"] = initViewObject - f = open(filePath,"w") - json.dump(cfg_content,f,indent=4) - f.close() - - except Exception: - if f is not None: - f.close() - print("parser %s file failure!" % filePath) - - # parse arguments -def parse_args(): - """Custom and check param list. - """ - from argparse import ArgumentParser - parser = ArgumentParser(description="Init project configure", epilog="This is a epilog of %(prog)s") - parser.add_argument("-n", "--name", metavar="VIEW_NAME", help="Set view name") - parser.add_argument("-w", "--width", metavar="VIEW_WIDTH", help="Init view size for width") - parser.add_argument("-i", "--hight", metavar="VIEW_HEIGHT", help="Init view size for height") - parser.add_argument("--landscape", action="store_true", dest="no_native", help="Set screen Orientation") - args = parser.parse_args() - - setConfigJson(args.name,args.width,args.hight) - setAndroidOrientation(args.landscape) - -if __name__ == '__main__': - parse_args() - - -