geonode.upload.files

An incomplete replacement for the various file support functions currently scattered over the codebase

@todo complete and use

Attributes

logger

vector

raster

xml_unsafe

TYPE_UNKNOWN

_keep_original_data

_tif_extensions

_mosaics_extensions

types

Classes

SpatialFiles

A more or less complete user-defined wrapper around list objects.

SpatialFile

FileType

Functions

get_type(name)

_contains_bad_names(file_names)

return True if the list of names contains a bad one

_clean_string(str[, regex, replace])

Replaces a string that matches the regex with the replacement.

_rename_files(file_names)

_find_file_type(file_names, extension)

Returns files that end with the given extension from a list of file names.

clean_macosx_dir(file_names)

Returns the files sans anything in a __MACOSX directory

get_scan_hint(valid_extensions)

Provide hint on the type of file being handled in the upload session.

scan_file(file_name[, scan_hint, charset])

get a list of SpatialFiles for the provided file

_process_zip(zip_path, destination_dir[, scan_hint, ...])

Perform sanity checks on uploaded zip file

_sanitize_zip_contents(zip_handler, destination_dir, ...)

_extract_zip(zip_handler, destination, charset)

_probe_zip_for_sld(zip_handler, destination_dir)

Module Contents

geonode.upload.files.logger[source]
geonode.upload.files.vector[source]
geonode.upload.files.raster[source]
geonode.upload.files.xml_unsafe[source]
class geonode.upload.files.SpatialFiles(dirname, data, archive=None)[source]

Bases: collections.UserList

A more or less complete user-defined wrapper around list objects.

dirname[source]
data[source]
archive[source]
all_files()[source]
class geonode.upload.files.SpatialFile(base_file, file_type, auxillary_files, sld_files, xml_files)[source]
base_file[source]
file_type[source]
auxillary_files[source]
sld_files[source]
xml_files[source]
all_files()[source]
__repr__()[source]
class geonode.upload.files.FileType(name, code, dataset_type, aliases=None, auxillary_file_exts=None)[source]
name[source]
code[source]
dataset_type[source]
aliases[source]
auxillary_file_exts[source]
matches(ext)[source]
build_spatial_file(base, others)[source]
find_auxillary_files(base, others)[source]
__repr__()[source]
geonode.upload.files.TYPE_UNKNOWN[source]
geonode.upload.files._keep_original_data = ('kmz', 'zip-mosaic')[source]
geonode.upload.files._tif_extensions = ('tif', 'tiff', 'geotif', 'geotiff')[source]
geonode.upload.files._mosaics_extensions = ('properties', 'shp', 'aux')[source]
geonode.upload.files.types[source]
geonode.upload.files.get_type(name)[source]
geonode.upload.files._contains_bad_names(file_names)[source]

return True if the list of names contains a bad one

geonode.upload.files._clean_string(str, regex='(^[^a-zA-Z\\._]+)|([^a-zA-Z\\._0-9]+)', replace='_')[source]

Replaces a string that matches the regex with the replacement.

geonode.upload.files._rename_files(file_names)[source]
geonode.upload.files._find_file_type(file_names, extension)[source]

Returns files that end with the given extension from a list of file names.

geonode.upload.files.clean_macosx_dir(file_names)[source]

Returns the files sans anything in a __MACOSX directory

geonode.upload.files.get_scan_hint(valid_extensions)[source]

Provide hint on the type of file being handled in the upload session.

This function is useful mainly for those file types that can carry either vector or raster formats, like the KML type.

geonode.upload.files.scan_file(file_name, scan_hint=None, charset=None)[source]

get a list of SpatialFiles for the provided file

geonode.upload.files._process_zip(zip_path, destination_dir, scan_hint=None, charset=None)[source]

Perform sanity checks on uploaded zip file

This function will check if the zip file’s contents have legal names. If they do the zipfile remains compressed. Otherwise, it is extracted and the files are renamed.

It will also check if an .sld file exists inside the zip and extract it

geonode.upload.files._sanitize_zip_contents(zip_handler, destination_dir, charset)[source]
geonode.upload.files._extract_zip(zip_handler, destination, charset)[source]
geonode.upload.files._probe_zip_for_sld(zip_handler, destination_dir)[source]