Exemplo n.º 1
0
 def can_add_child(self, child):
     """ 
     return true if 'child' can be add to self 
     """
     if not self.is_valid_child(child):
         return False
     if child.isa == u'PBXGroup':
         return len(func.take(\
             lambda c: c.pbx_name == child.pbx_name and c.realpath() == child.realpath(),\
             self.pbx_children)) == 0
     else:
         return len(
             func.take(lambda c: c.realpath() == child.realpath(),
                       self.pbx_children)) == 0
Exemplo n.º 2
0
    def get_build_phase(self, isa, name=None, create=False):
        """ get build phase, create a new one if not exists """
        def __cmp(phase):
            if phase.isa == isa:
                return True if name is None else phase.displayname() == name
            return False

        bp = func.get_list_item(func.take(lambda o:__cmp(o), self.pbx_buildPhases), 0)
        if bp is None and create:
            bp = self.create_build_phase(isa, name)
        return bp
Exemplo n.º 3
0
    def getconfig(self, name, auto_create=False):
        """ return config with name, otherwise return None """
        if name is None:
            return None

        config = func.get_list_item(\
            func.take(lambda c: c.pbx_name == name, self.pbx_buildConfigurations), 0)
        if config is None and auto_create:
            config = self.project().new_object(u'XCBuildConfiguration')
            config.pbx_name = name
            self.addconfig(config)
        return config
Exemplo n.º 4
0
def pbxobj_has_pbxlist_value(obj, attr, value, validator):
    """
    return True if attribute 'name' of pbxobject 'obj' contains 'val'
    :param  obj:  object to check
    :param  attr:  pbxattribute name
    :param  value: value(pbxobject or guid) to check
    :param  validator: check if item is valid
    """
    guid = None
    if is_valid_guid(value):
        guid = value
    elif validator(value):
        guid = value.guid
    return not guid is None and len(
        func.take(lambda o: o.guid == guid, getattr(obj, attr, []))) > 0
Exemplo n.º 5
0
 def __replace_array_item(array, keys, oldval, newval):
     if len(keys) > 0:
         for subval in array:
             __recursively_check_and_replace(subval, list(keys), oldval,
                                             newval)
     else:
         idx = 0
         while idx < len(array):
             subval = array[idx]
             if isinstance(
                     subval,
                     PBXBaseObject) and subval.guid == oldval.guid:
                 if newval is None:
                     array.pop(idx)
                 else:
                     if len(
                             func.take(lambda a: a.guid == newval.guid,
                                       array)) == 0:
                         array[idx] = newval
                         newval.add_referrer(self, keypath)
                 subval.remove_referrer(self)
             idx += 1
Exemplo n.º 6
0
 def addgroup(self,
              abspath=None,
              sourcetree=pbxconsts.SOURCE_TREE.group,
              name=None,
              move=True):
     """
     return the group object specified the 'abspath',  not include the children
     :param abspath:     the group's abspath in disk, if None, using the parent's path
     """
     group_name = os.path.basename(
         abspath) if name is None or len(name) == 0 else name
     abspath = abspath if not abspath is None else self.realpath()
     subgroup = func.get_list_item(func.take(\
         lambda o: o.isa == u'PBXGroup' and o.realpath() == abspath \
         and o.displayname() == group_name, self.pbx_children), 0)
     if subgroup is None:
         subgroup = self.project().new_object(u'PBXGroup')
         pbxpath.set_path_with_source_tree(subgroup, abspath, source_tree=sourcetree, \
             parent_group=self)
         if not name is None:
             subgroup.pbx_name = name
     self.addchild(subgroup, move=move)
     return subgroup
Exemplo n.º 7
0
 def get_variant_group(self, abspath, name):
     """ return the variant group in specified path and name """
     return func.get_list_item(\
         func.take(lambda o: o.realpath() == abspath and o.pbx_name == name, \
             self.__objects.get(u'PBXVariantGroup', default=dict()).values()), 0)
Exemplo n.º 8
0
 def fileref_for_path(self, abspath):
     """ return the filereferece object with abspath in disk """
     return func.get_list_item(\
         func.take(lambda o: o.realpath() == abspath, \
             self.__objects.get(u'PBXFileReference', default=dict()).values()), 0)
Exemplo n.º 9
0
 def need_validate(self):
     """
     return True if there is any object need validate.
     """
     return len(func.take(lambda o: o[1].isdirty() and len(o[1].referrers()) > 0, \
         self.__objects.guid_items())) > 0
Exemplo n.º 10
0
 def gettarget(self, name):
     return func.get_list_item(func.take(lambda o:o.pbx_name == name, self.pbx_targets), 0)