Example #1
0
    def check_setup_called(self):
        # Find parent path that contains AppDelegate.swift
        parent_path_containing_target, filename = recursively_find_parent_containing_file(
            self.data_models_path, ["AppDelegate.swift", "AppDelegate.m"])
        if parent_path_containing_target is None:
            warn(
                "Warning: Unable to find AppDelegate.swift or AppDelegate.m to verify "
                "sharedDataModel().setup() is called")
            return False

        # Walk the file looking for setup call
        with open(parent_path_containing_target + os.sep + filename) as f:
            for line in f:
                # Looking for either the objective-c version or the swift version of the setup call.
                # Assuming roughly the following format:
                # Objective-c: [[DataModel sharedDataModel] setup]
                # Swift:       DataModel.sharedDataModel().setup()
                data_model_index = line.find("DataModel")
                shared_data_model_index = line.find("sharedDataModel")
                setup_index = line.find("setup")
                if 0 <= data_model_index and \
                   data_model_index < shared_data_model_index and \
                   shared_data_model_index < setup_index:
                    return True

        warn(
            "Warning: Did not find sharedDataModel().setup() call inside AppDelegate.swift"
        )
        return False
Example #2
0
 def process_attribute(self, attribute):
     if attribute == self.OPTIONAL:
         self.optional = True
     elif attribute == self.PRIMARY_KEY:
         self.primary_key = True
     elif attribute == self.ARRAY:
         self.array = True
     elif attribute in self.TYPES:
         self.field_type = attribute
     else:
         if attribute.startswith("$"):
             raise SignalsError("Found an unexpected attribute: {} on {}. "
                                "Likely it's missing relationship type.".format(attribute, self.name))
         warn("Found an unexpected attribute: {} on {}.".format(attribute, self.name))
Example #3
0
 def validate_json(self, url_json):
     # Verify there are no extra or improperly formatted attributes
     for attribute, value in url_json.iteritems():
         if attribute not in self.VALID_ATTRIBUTES:
             warn("Found unsupported attribute, {}, for url: {}".format(
                 attribute, self.url_path))
Example #4
0
 def validate_json(self, url_json):
     # Verify there are no extra or improperly formatted attributes
     for attribute, value in url_json.iteritems():
         if attribute not in self.VALID_ATTRIBUTES:
             warn("Found unsupported attribute, {}, for url: {}".format(attribute, self.url_path))