123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- # coding=utf-8
- """ 广告管理工程 """
- import os
- import ConfigParser
- from sdk.tool.ad_ecpm_config_txt import AdEcpmConfigTxt
- class SdkProject(object):
- """ 广告工程管理
- 成员变量:
- config_parser: ConfigParser
- project_name: string 工程名
- ios_bundle_id: string iOS的字符串包名
- root_dir: string 工程所在目录
- game_platform: string 游戏所在平台(android或ios)
- package: string 包名, iOS平台的话为appId(数字)
- """
- def __init__(self):
- self.config_parser = ConfigParser.ConfigParser()
- self.project_name = ""
- self.game_platform = ""
- self.package = ""
- self.ios_bundle_id = ""
- self.root_dir = ""
- def read(self, ini_path):
- self.config_parser.read(ini_path)
- section_project = "project"
- self.project_name = self.config_parser.get(section_project, "name")
- self.game_platform = self.config_parser.get(section_project, "game_platform")
- self.package = self.config_parser.get(section_project, "package")
- self.ios_bundle_id = self.config_parser.get(section_project, "ios_bundle_id")
- section_path = "path"
- self.root_dir = self.config_parser.get(section_path, "root")
- def __find_ecmp_confid_txt(self, file_name_mark):
- txt_dir = os.path.join(self.root_dir, "ecpm_config_txts")
- files = os.listdir(txt_dir)
- for file_name in files:
- if file_name.find(file_name_mark) != -1:
- txt = AdEcpmConfigTxt()
- txt.read(os.path.join(txt_dir, file_name))
- return txt
- def banner_ecpm_config_txt(self):
- """ 读取Banner配置文件
- :return: AdEcpmConfigTxt
- """
- return self.__find_ecmp_confid_txt("banner")
- def inter_ecpm_config_txt(self):
- """ 读取Inter配置文件
- :return: AdEcpmConfigTxt
- """
- return self.__find_ecmp_confid_txt("inter")
- def print_desc(self):
- print "工程名: \t\t\t {}".format(self.project_name)
- print "游戏平台: \t\t {}".format(self.game_platform)
- print "包名: \t\t\t {}".format(self.package)
- if not self.ios_bundle_id:
- print "iOS bundle id: \t {}".format(self.ios_bundle_id)
- print "工程目录: \t\t {}".format(self.root_dir)
- if __name__ == '__main__':
- proj = SdkProject()
- proj.read("/Users/zhuge/datas/AdProjects/ShootingZombie-2D射击-Android/project.ini")
- proj.print_desc()
- print "banner 国家数: {}".format(proj.banner_ecpm_config_txt().country_count)
- print "inter 国家数: {}".format(proj.inter_ecpm_config_txt().country_count)
|