Skip to content

Commit

Permalink
fix bug that always create a new project file
Browse files Browse the repository at this point in the history
  • Loading branch information
临寒 committed Aug 3, 2014
1 parent 3d6b62b commit 99f88bd
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions xUnique.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from __future__ import unicode_literals
from subprocess import (check_output as sp_co, check_call as sp_cc)
from os import path, unlink
from os import path, unlink, rename
from hashlib import md5 as hl_md5
import json
from urllib import urlretrieve
Expand Down Expand Up @@ -198,9 +198,10 @@ def file_dir_cmp(x, y):
fc_end_ptn = re_compile(files_match.group(1) + fc_end_ptn)
if files_flag:
if fc_end_ptn.search(line):
lines.sort(key=lambda file_str: files_key_ptn.search(file_str).group())
print ''.join(lines),
lines = []
if lines:
lines.sort(key=lambda file_str: files_key_ptn.search(file_str).group())
print ''.join(lines),
lines = []
files_flag = False
fc_end_ptn = '\);'
elif files_key_ptn.search(line):
Expand All @@ -214,10 +215,11 @@ def file_dir_cmp(x, y):
fc_end_ptn = re_compile(children_match.group(1) + fc_end_ptn)
if child_flag:
if fc_end_ptn.search(line):
if last_two[0] != self.__main_group_hex:
lines.sort(key=lambda file_str: children_pbx_key_ptn.search(file_str).group(),cmp=file_dir_cmp)
print ''.join(lines),
lines = []
if lines:
if last_two[0] != self.__main_group_hex:
lines.sort(key=lambda file_str: children_pbx_key_ptn.search(file_str).group(),cmp=file_dir_cmp)
print ''.join(lines),
lines = []
child_flag = False
fc_end_ptn = '\);'
elif children_pbx_key_ptn.search(line):
Expand All @@ -231,9 +233,10 @@ def file_dir_cmp(x, y):
pbx_end_ptn = re_compile(pbx_match.group(1).join(pbx_end_ptn))
if pbx_flag:
if pbx_end_ptn.search(line):
lines.sort(key=lambda file_str: children_pbx_key_ptn.search(file_str).group())
print ''.join(lines),
lines = []
if lines:
lines.sort(key=lambda file_str: children_pbx_key_ptn.search(file_str).group())
print ''.join(lines),
lines = []
pbx_flag = False
pbx_end_ptn = ('^.*End ', ' section.*')
elif children_pbx_key_ptn.search(line):
Expand All @@ -244,6 +247,8 @@ def file_dir_cmp(x, y):
fi_close()
tmp_path = self.xcode_pbxproj_path + '.bak'
if filecmp_cmp(self.xcode_pbxproj_path, tmp_path, shallow=False):
unlink(self.xcode_pbxproj_path)
rename(tmp_path,self.xcode_pbxproj_path)
print 'Ignore, no changes made to {}'.format(self.xcode_pbxproj_path)
else:
unlink(self.xcode_pbxproj_path + '.bak')
Expand Down

0 comments on commit 99f88bd

Please sign in to comment.