Example #1
0
 def issues(self):
     data = []
     path_metadata = self.path_metadata()
     for path in Files.find(Files.path_combine(self.path(), '*.json')):
         if path != path_metadata:
             data.append(Json.load_file(path))
     return data
Example #2
0
    def create__by_key(self):
        all_data = {}
        file_filter = Files.path_combine(self.file_system.folder_data,
                                         '**/*.json')
        for path in Files.find(file_filter):
            if self.filename_metadata not in path:  # don't load metadata file
                data = Json.load_file(path)
                key = data.get('Key')
                all_data[key] = {
                    'path': path.replace(self.file_system.folder_data, '')[1:],
                    'links': {},
                    'data': data,
                }

        for link in self.links.all():
            from_key = link[0]
            link_type = link[1]
            to_key = link[2]
            issue = all_data.get(from_key)
            if issue:
                links = issue.get('links')
                if links.get(link_type) is None: links[link_type] = []
                links[link_type].append(to_key)

        Json.save_file_pretty(self.path__by_key(), all_data)
        return all_data
def run(event, context):
    file_name = event.get('file_name')  # get file_name from lambda params
    tmp_path = '/tmp'  # location of lambda temp folder
    tmp_file = Files.path_combine(
        tmp_path, file_name)  # create file name (in temp folder)

    Files.write(tmp_file, 'some text')  # create file (with some text)

    return Files.find(tmp_path + '/*.*')  # return list of files in temp folder
Example #4
0
    def test_upload(self):
        tmp_folder = Temp_Folder_With_Lambda_File(
            self.lambda_name).create_temp_file()

        (self.aws_lambda.set_s3_bucket(self.s3_bucket).set_s3_key(
            self.s3_key).set_folder_code(tmp_folder.folder))

        downloaded_file = self.aws_lambda.s3().file_download(
            self.s3_bucket, self.s3_key)  # download file uploaded
        assert file_exists(downloaded_file) is True
        unzip_location = tmp_folder.folder + '_unzipped'
        Files.unzip_file(downloaded_file, unzip_location)  # unzip it
        assert file_contents(Files.find(unzip_location + '/*').pop(
        )) == tmp_folder.lambda_code  # confirm unzipped file's contents

        self.aws_lambda.s3().file_delete(self.s3_bucket, self.s3_key)
Example #5
0
 def by_issue_type(self,issue_type_name, indexed_by=None):
     data = []
     file_filter = "{0}/{1}/{2}".format(self.file_system.folder_data, issue_type_name ,'*.json')
     for path in Files.find(file_filter):
         if self.filename_metadata not in path:          # don't load metadata file
             data.append(Json.load_file(path))
     if indexed_by is None:
         return data
     indexed_data = {}
     for item in data:
         key   = item.get('Key')
         index = item.get(indexed_by)
         if index:
             if indexed_data.get(index) is None: indexed_data[index] = {}
             indexed_data[index][key] = item
     return indexed_data