예제 #1
0
    def init_strava_schema_from_file():

        LoadTestData.init_foaf()

        rdf_inst = RdfInstanceService()

        data_cleaning = DataCleaningService()

        # load the file
        testfile = os.path.join(
            settings.BASE_DIR,
            "MetaDataApi/metadata/tests/data/json/strava_activities.json")
        data = JsonUtils.read_json_file(testfile)

        service = JsonAnalyser()

        schema_label = "strava"
        label = "activities"

        schema = Schema.create_new_empty_schema(schema_label)

        user = LoadTestData.init_user()
        LoadTestData.init_profile(user)

        service.identify_from_json_data(data,
                                        schema,
                                        user,
                                        parrent_label=label)
        data_cleaning.relate_root_classes_to_foaf(schema)

        return schema
 def try_get_result_data_or_create_it(self, input_filename, result_data):
     result_file_path = self.build_result_file_path(input_filename)
     try:
         return JsonUtils.read_json_file(result_file_path)
     except FileNotFoundError:
         JsonUtils.write_to_file(result_data, result_file_path)
         raise FileNotFoundError(f"Expected result did not exists before but has now been created, "
                                 f"check the file {result_file_path} to ensure the result is correct", )
 def get_data_providers_from_local_or_remote_file(cls):
     try:
         return JsonUtils.read_json_file(cls.data_providers_filename)
     except FileNotFoundError as e:
         return cls.get_providers_from_aws()
     except Exception as e:
         logger.error(
             f"another error than fileNotFound has occured Msg: {e}")
         return cls.get_providers_from_aws()
예제 #4
0
    def init_strava_data_from_file():
        user = LoadTestData.init_user()
        LoadTestData.init_profile(user)

        service = JsonAnalyser()

        # load the file
        testfile = os.path.join(
            settings.BASE_DIR,
            "MetaDataApi/metadata/tests/data/json/strava_activities.json")
        data = JsonUtils.read_json_file(testfile)

        schema = Schema.objects.get(label="strava")

        label = "activities"

        objects = service.identify_from_json_data(data,
                                                  schema,
                                                  parrent_label=label,
                                                  owner=user)

        return objects
 def try_read_json_file(self, filename):
     try:
         JsonUtils.read_json_file(filename)
     except FileNotFoundError:
         pass
예제 #6
0
 def loadStravaActivities(cls):
     testfile = os.path.join(
         settings.BASE_DIR,
         "metadata/tests/data/json/strava_activities.json")
     data = JsonUtils.read_json_file(testfile)
     return data