Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sheet_meta(sheet_meta):
from adhocracy_core.sheets import AnnotationStorageSheet
from adhocracy_core.interfaces import ISheet
class SheetASchema(colander.MappingSchema):
count = colander.SchemaNode(colander.Int(),
missing=colander.drop,
default=0)
meta = sheet_meta._replace(isheet=ISheet,
schema_class=SheetASchema,
sheet_class=AnnotationStorageSheet,
readable=True,
editable=True,
creatable=True)
return meta
import numpy as np
from colander import SchemaNode, String, Float, drop, SequenceSchema, Sequence
import unit_conversion
from gnome.persist import base_schema
from gnome.environment.gridded_objects_base import Time, TimeSchema
from gnome.gnomeobject import GnomeId
from gnome.persist.extend_colander import NumpyArraySchema
class TimeseriesDataSchema(base_schema.ObjTypeSchema):
units = SchemaNode(
String(), missing=drop, save=True, update=True
)
time = TimeSchema(
save=True, update=True, save_reference=True
)
data = NumpyArraySchema(
missing=drop, save=True, update=True
)
class TimeseriesData(GnomeId):
'''
Base class for data with a single dimension: time
'''
_schema = TimeseriesDataSchema
def _add_additional_nodes(self, schema: MappingSchema,
params: dict):
if params.get('serialization_form', False) == 'content':
elements = schema['elements']
typ_copy = deepcopy(elements.children[0].typ)
typ_copy.serialization_form = 'content'
elements.children[0].typ = typ_copy
if params.get('show_count', True): # pragma: no branch
child = Integer(default=0,
missing=drop,
name='count')
schema.add(child)
if params.get('show_frequency', False):
child = SchemaNode(MappingType(unknown='preserve'),
default={},
missing=drop,
name='aggregateby')
schema.add(child)
return schema
from gnome.persist import base_schema
from gnome.environment.gridded_objects_base import Time, TimeSchema
from gnome.gnomeobject import GnomeId
from gnome.persist.extend_colander import NumpyArraySchema
class TimeseriesDataSchema(base_schema.ObjTypeSchema):
units = SchemaNode(
String(), missing=drop, save=True, update=True
)
time = TimeSchema(
save=True, update=True, save_reference=True
)
data = NumpyArraySchema(
missing=drop, save=True, update=True
)
class TimeseriesData(GnomeId):
'''
Base class for data with a single dimension: time
'''
_schema = TimeseriesDataSchema
def __init__(self,
data=None,
time=None,
units=None,
extrapolate=True,
*args,
from gnome.basic_types import oil_status
from .outputter import Outputter, BaseOutputterSchema
from gnome.persist.extend_colander import FilenameSchema
from . import kmz_templates
class KMZSchema(BaseOutputterSchema):
'''
Nothing is required for initialization
'''
# round_data = SchemaNode(Bool(), missing=drop)
# round_to = SchemaNode(Int(), missing=drop)
filename = FilenameSchema(
missing=drop, save=True, update=True, test_equal=False
)
class KMZOutput(Outputter):
'''
class that outputs GNOME results in a kmz format.
Suitable for Google Earth, and semi-suitable for MarPlot
'''
_schema = KMZSchema
time_formatter = '%m/%d/%Y %H:%M'
def __init__(self, filename, **kwargs):
'''
tag = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(colander.String()),
missing=colander.drop,
description="Limit the results to annotations tagged with the specified value.",
)
tags = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(colander.String()),
missing=colander.drop,
description="Alias of tag.",
)
text = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(colander.String()),
missing=colander.drop,
description="Limit the results to annotations that contain this text in their textual body.",
)
uri = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(colander.String()),
missing=colander.drop,
description="""Limit the results to annotations matching the specific URI
or equivalent URIs. URI can be a URL (a web page address) or
a URN representing another kind of resource such as DOI
(Digital Object Identifier) or a PDF fingerprint.""",
)
uri_parts = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(colander.String()),
name="uri.parts",
missing=colander.drop,
Weathering Outputter
'''
import os
import copy
from glob import glob
from geojson import dump
from colander import SchemaNode, String, drop
from .outputter import Outputter, BaseOutputterSchema
class WeatheringOutputSchema(BaseOutputterSchema):
output_dir = SchemaNode(
String(), missing=drop, save=True, update=True
)
class WeatheringOutput(Outputter):
'''
class that outputs GNOME weathering results.
The output is the aggregation of properties for all LEs (aka Mass Balance)
for a particular time step.
There are a number of different things we would like to graph:
- Evaporation
- Dissolution
- Dissipation
- Biodegradation
- ???
However at this time we will simply try to implement an outputter for the
id = colander.SchemaNode(colander.Float())
name = colander.SchemaNode(colander.String())
address_1 = colander.SchemaNode(colander.String())
country = colander.SchemaNode(colander.String())
name = colander.SchemaNode(colander.String())
headcount = colander.SchemaNode(colander.Integer())
description = colander.SchemaNode(colander.String(), missing="")
visibility = colander.SchemaNode(colander.String())
duration = colander.SchemaNode(colander.Integer(),
missing=colander.drop)
maybe_rsvp_count = colander.SchemaNode(colander.Integer())
yes_rsvp_count = colander.SchemaNode(colander.Integer())
rsvp_limit = colander.SchemaNode(colander.Integer(),
missing=colander.drop)
waitlist_count = colander.SchemaNode(colander.Integer())
class IDocument(IProperty):
"""Marker interface representing a Fubel with document data."""
taggedValue('schema', 'adhocracy.properties.interfaces.DocumentSchema')
class DocumentSchema(colander.Schema):
"""Colander schema for IDocument."""
elements = ReferenceSetSchemaNode(
essence_refs=True,
default=[],
missing=colander.drop,
interface='adhocracy.resources.interfaces.ISection')
class ISection(IProperty):
"""Marker interface representing a document section."""
taggedValue('schema', 'adhocracy.properties.interfaces.SectionSchema')
class SectionSchema(colander.Schema):
"""Colander schema for ISection."""
title = colander.SchemaNode(colander.String(), default='')
elements = ReferenceSetSchemaNode(