当前位置: 首页>>代码示例>>Python>>正文


Python XcodeProject.load方法代码示例

本文整理汇总了Python中pbxproj.XcodeProject.load方法的典型用法代码示例。如果您正苦于以下问题:Python XcodeProject.load方法的具体用法?Python XcodeProject.load怎么用?Python XcodeProject.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pbxproj.XcodeProject的用法示例。


在下文中一共展示了XcodeProject.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_files_to_project

# 需要导入模块: from pbxproj import XcodeProject [as 别名]
# 或者: from pbxproj.XcodeProject import load [as 别名]
def save_files_to_project(project_directory, internal_file_names, external_file_names):

	fileschanged = False
	projectName = ''
	searchDirectory = project_directory + '/../'
	for filepath in filter(lambda x: x.endswith('.xcodeproj'), os.listdir(searchDirectory)):
		projectName = filepath.partition('.')[0]

	project_file_path = project_directory +'../' + projectName + '.xcodeproj'
	backup_project_path = project_file_path + '-backup'

	print '1 - ' + project_directory
	print '2 - ' + project_file_path

	if os.path.exists(os.path.dirname(backup_project_path + '/')):
		shutil.rmtree(backup_project_path + '/')

	shutil.copytree(project_file_path, backup_project_path)

	project = XcodeProject.load(project_file_path + '/project.pbxproj')
	#backup_file = project.backup()

	parent_group = project.get_or_create_group(projectName)
	model_group = project.get_or_create_group('Model', parent=parent_group)
	mapping_group = project.get_or_create_group('Mapping', parent=model_group)
	internal_group = project.get_or_create_group('Internal', parent=model_group)

	#print('Project Name ' + projectName + ' Path ' + project_file_path)
	#print 'Backup File Name ' + backup_file

	for internal_name in internal_file_names:
		found_files = project.get_files_by_name(internal_name)
		if len(found_files) == 0:
			fileschanged = True
			internal_path = project_directory + '/Model/Internal/' + internal_name
			print '3 - ' + internal_path
			project.add_file(internal_path, parent=internal_group, force=False)

	for external_name in external_file_names:
		found_files = project.get_files_by_name(external_name)

		if len(found_files) == 0:
			fileschanged = True
			external_path = project_directory + '/Model/' + external_name
			print '4 - ' + external_path
			project.add_file(external_path, parent=model_group, force=False)

	if fileschanged:
		try:
			print('PROJECT SAVED')
			project.save()
		except:
			print('FAILED PROJECT SAVE')
		else:
			os.remove(backup_file)
开发者ID:AntonTheDev,项目名称:JSONModelKit,代码行数:57,代码来源:modelgen-swift.py

示例2: importmodelfiles

# 需要导入模块: from pbxproj import XcodeProject [as 别名]
# 或者: from pbxproj.XcodeProject import load [as 别名]
   def importmodelfiles():
   		instantiatorPath = output_directory + 'Internal/JMInstantiator.swift'
		instantiatorGenerator = InstantiatorGenerator(plistPaths, output_directory, version, testEnabled, jsonFormatEnabled)

		generate_file(instantiatorGenerator.internalGeneratedClass(), instantiatorPath, True)

        # open the project
		project = XcodeProject.load('myapp.xcodeproj/project.pbxproj')

		for mappingPath in plistPaths:
			classname = mappingPath[mappingPath.rindex('/',0,-1)+1:-1] if mappingPath.endswith('/') else mappingPath[mappingPath.rindex('/')+1:].split('.', 1 )[0]

			classGenerator = ClassGenerator(mappingPath, output_directory, version, testEnabled, jsonFormatEnabled)

			internalClassPath = output_directory + 'Internal/_'+ classname + '.swift'
			externalClassPath = output_directory + classname + '.swift'
开发者ID:AntonTheDev,项目名称:JSONModelKit,代码行数:18,代码来源:fileimporter.py


注:本文中的pbxproj.XcodeProject.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。