Python:Topic
Appearance
from dataclasses import dataclass from typing import Optional import dacite @dataclass class Topic:
""" A Topic is a Concept/Class/Thing/Entity """ pageTitle:str name:Optional[str] # The name of the topic pluralName:Optional[str] # The plural of a topic name. E.g. for the topic 'City' the pluralName is 'Cities'. If no pluralName is specified an 's' is appended. E.g. for the topic 'Book' the default pluralName is 'Books' isA:Optional[str] # The metamodel kind of the topic extends:Optional[str] # this topic specializes the topic it extends (if any) icon:Optional[str] # an Icon for the topic iconUrl:Optional[str] # the url of an icon documentation:Optional[str] # The plaintext documentation of a Topic. Please do not use markup for this. wikiDocumentation:Optional[str] # Documentation of the Topic using MediaWiki / Semantic Mediawiki markup defaultstoremode:Optional[str] # The default storemode of the topic listLimit:Optional[float] # What is the default #ask list limit for this Topic? cargo:Optional[bool] # Should the Topic be stored using the Cargo Extension? headerTabs:Optional[bool] # shall the forms be generated with header tabs? context:Optional[str] # the context this topic belongs to
@classmethod
def askQuery(cls):
"""
get the ask Query for Topic
Returns:
str: the mediawiki markup for the ask query
"""
ask="""
| pageTitle | name | pluralName | isA | extends | icon | iconUrl | documentation | wikiDocumentation | defaultstoremode | listLimit | cargo | headerTabs | context |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Action | Action | Actions | /images/e/eb/Actionicon.png | An action/function/operation to be performed | An action/function/operation to be performed | subobject | 200 | false | MetaModel | ||||
| Context | Context | Contexts | /images/d/d2/Registry.png | A Context groups some topics like a Namespace/Package | A Context groups some topics like a Namespace/Package | property | 200 | false | MetaModel | ||||
| Leg | Leg | Legs | /images/1/1c/Flag-Icon.png | A segment of a trip between two locations with one mode of transport | A leg is one segment of a trip between two locations travelled with a single mode of transport on a given date. Legs are ordered by num within their trip page. | subobject | 200 | false | TripContext | ||||
| Loc | Loc | Locations | /images/thumb/2/2a/Location_pin_icon.png/128px-Location_pin_icon.png | A location of a trip such as a city, station, port or hotel | A location referenced by the legs of a trip by its id. The Wikidata item links the location to the map options of velorail; the coordinates feed the map of the trip. | subobject | 200 | false | TripContext | ||||
| Property | Property | Properties | /images/6/6a/Element_into_input.png | a Property is a Feature/Attribute of a Topic | see | property | 200 | false | MetaModel | ||||
| SMW Type | SMW_Type | SMW_Types | /images/4/40/Component.png | an SMW_Type is a data type which determines the possible values for that type e.g. a Boolean can hold true/false values while a Number can hold 3.1459 or 20. A Page can hold the name of a Wiki page see https://semantic-mediawiki.org/wiki/Help:List_of_datatypes | see
| subobject | 200 | false | MetaModel | ||||
| Topic | Topic | Topics | /images/a/ae/Index.png | A Topic is a Concept/Class/Thing/Entity | A Topic is a Concept/Class/Thing/Entity | property | 200 | false | MetaModel | ||||
| TopicLink | TopicLink | TopicLinks | /images/f/fd/Link.png | A TopicLink links two Concepts | A TopicLink links two Concept:Topics | subobject | 200 | false | MetaModel | ||||
| Trip | Trip | Trips | /images/thumb/0/09/Tour-Icon.png/128px-Tour-Icon.png | A trip from a start location to a destination consisting of ordered legs | A trip is the root of a journey: it has a start and a destination, a time span and an ordered list of legs between locations. Legs and locations are stored as subobjects on the trip page. | property | 200 | false | TripContext |
"""
return ask
@classmethod
def fromDict(cls,data:dict):
"""
create a Topic from the given dict
Args:
data(dict): the dict to create the Topic from
Returns:
Topic: the freshly created Topic
"""
topic=dacite.from_dict(data_class=cls,data=data)
return topic