Jump to content

Python:Topic

From tripwiki

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="""

pageTitlenamepluralNameisAextendsiconiconUrldocumentationwikiDocumentationdefaultstoremodelistLimitcargoheaderTabscontext
ActionActionActions
/images/e/eb/Actionicon.png
An action/function/operation to be performedAn action/function/operation to be performedsubobject200falseMetaModel
ContextContextContexts
/images/d/d2/Registry.png
A Context groups some topics like a Namespace/PackageA Context groups some topics like a Namespace/Packageproperty200falseMetaModel
LegLegLegs
/images/1/1c/Flag-Icon.png
A segment of a trip between two locations with one mode of transportA 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.subobject200falseTripContext
LocLocLocations
/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 hotelA 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.subobject200falseTripContext
PropertyPropertyProperties
/images/6/6a/Element_into_input.png
a Property is a Feature/Attribute of a Topicsee property200falseMetaModel
SMW TypeSMW_TypeSMW_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_datatypessee
  • https://semantic-mediawiki.org/wiki/Special:Types
  • https://semantic-mediawiki.org/wiki/Help:List_of_datatypes
  • subobject200falseMetaModel
    TopicTopicTopics
    /images/a/ae/Index.png
    A Topic is a Concept/Class/Thing/EntityA Topic is a Concept/Class/Thing/Entityproperty200falseMetaModel
    TopicLinkTopicLinkTopicLinks
    /images/f/fd/Link.png
    A TopicLink links two ConceptsA TopicLink links two Concept:Topicssubobject200falseMetaModel
    TripTripTrips
    /images/thumb/0/09/Tour-Icon.png/128px-Tour-Icon.png
    A trip from a start location to a destination consisting of ordered legsA 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.property200falseTripContext

    """

           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