Ejemplo n.º 1
0
def resource_with_id_and_filename(filename, dataset, obj_id):
    from mcod.resources.models import Resource
    full_filename = prepare_file(filename)
    with open(full_filename, 'rb') as outfile:
        if is_enabled('S40_new_file_model.be'):
            res = Resource.objects.create(
                id=obj_id,
                title='Local file resource',
                description='Resource with file',
                dataset=dataset,
                data_date=datetime.today(),
                status='published'
            )
            ResourceFileFactory.create(
                resource_id=res.pk,
                file=File(outfile),
            )
        else:
            Resource.objects.create(
                id=obj_id,
                title='Local file resource',
                description='Resource with file',
                file=File(outfile),
                dataset=dataset,
                data_date=datetime.today(),
                status='published'
            )
Ejemplo n.º 2
0
def no_data_resource(dataset):
    resource = Resource()
    resource.title = "No data resource"
    resource.type = "file"
    resource.format = 'JPG'
    if not is_enabled('S40_new_file_model.be'):
        resource.file = File(open(prepare_file('buzzfeed-logo.jpg'), 'rb'))
        resource.file.open('rb')
    resource.dataset = dataset
    resource.save()
    if is_enabled('S40_new_file_model.be'):
        ResourceFile.objects.create(file=File(
            open(prepare_file('buzzfeed-logo.jpg'), 'rb')),
                                    is_main=True,
                                    resource=resource,
                                    format='JPG')
    resource = Resource.objects.get(pk=resource.pk)
    return resource
Ejemplo n.º 3
0
def table_resource_with_invalid_schema(dataset):
    resource = Resource()
    resource.url = "http://smth.smwhere.com"
    resource.title = "File resource name"
    resource.type = "file"
    resource.format = 'XLSX'
    resource.file = File(open(prepare_file('wrong_schema_table.xlsx'), 'rb'))
    resource.file.open('rb')
    resource.dataset = dataset
    resource.save()
    return resource
Ejemplo n.º 4
0
def example_n_triples_file():
    # https://www.w3.org/TR/2014/REC-n-triples-20140225/Overview.html
    return prepare_file('rdf/example_n_triples.nt')
Ejemplo n.º 5
0
def empty_tar_gz_file():
    return prepare_file('empty_file.tar.gz')
Ejemplo n.º 6
0
def example_binary_netcdf():
    return prepare_file('madis-maritime.nc')
Ejemplo n.º 7
0
def shapefile_trees():
    return [prepare_file('iglaste.tar.xz'), prepare_file('iglaste_other.tar.xz')]
Ejemplo n.º 8
0
def example_trix_file():
    # https://www.w3.org/2004/03/trix/
    return prepare_file('rdf/example_trix.trix')
Ejemplo n.º 9
0
def example_grib():
    return prepare_file('example_grib.grib')
Ejemplo n.º 10
0
def single_csv_zip():
    return prepare_file('single_csv.zip')
Ejemplo n.º 11
0
def example_rdf_file():
    # https://www.w3.org/TR/REC-rdf-syntax/#example7
    return prepare_file('rdf/example_rdf.rdf')
Ejemplo n.º 12
0
def simple_csv_file():
    return prepare_file('simple.csv')
Ejemplo n.º 13
0
def single_file_pack():
    return prepare_file('single_file.tar.gz')
Ejemplo n.º 14
0
def example_xlsx_file():
    return prepare_file('sheet_img.xlsx')
Ejemplo n.º 15
0
def example_xls_file():
    return prepare_file('example_xls_file.xls')
Ejemplo n.º 16
0
def example_n_quads_file():
    # https://www.w3.org/TR/2014/REC-n-quads-20140225/
    return prepare_file('rdf/example_n_quads.nq')
Ejemplo n.º 17
0
def empty_tar_bz2_file():
    return prepare_file('empty_file.tar.bz2')
Ejemplo n.º 18
0
def multi_file_pack():
    return prepare_file('multi_file.rar')
Ejemplo n.º 19
0
def example_ods_file():
    return prepare_file('example_ods_file.ods')
Ejemplo n.º 20
0
def multi_file_zip_pack():
    return prepare_file('multi_pdf_xlsx.zip')
Ejemplo n.º 21
0
def example_trig_file():
    # https://www.w3.org/TR/2014/REC-trig-20140225/
    return prepare_file('rdf/example_trig.trig')
Ejemplo n.º 22
0
def shapefile_arch():
    return prepare_file('Mexico_and_US_Border.zip')
Ejemplo n.º 23
0
def example_turtle_file():
    # https://www.w3.org/TR/2014/REC-turtle-20140225/examples/example1.ttl
    return prepare_file('rdf/example_turtle.ttl')
Ejemplo n.º 24
0
def empty_zip_file():
    return prepare_file('empty_file.zip')
Ejemplo n.º 25
0
def example_hdf_netcdf():
    return prepare_file('darwin_2012.nc')
Ejemplo n.º 26
0
def example_kml_file():
    return prepare_file('example_kml.kml')
Ejemplo n.º 27
0
def shapefile_world():
    return [prepare_file('TM_WORLD_BORDERS-0.3.%s' % ext) for ext in ('shp', 'shx', 'prj', 'dbf')]
Ejemplo n.º 28
0
def empty_7z_file():
    return prepare_file('empty_file.7z')
Ejemplo n.º 29
0
def empty_rar_file():
    return prepare_file('empty_file.rar')
Ejemplo n.º 30
0
def example_n3_file():
    # https://w3c.github.io/N3/spec/#simpletriples
    return prepare_file('rdf/example_n3.n3')