parameters: (ship_name)
docstring: Write a given <ship>.json file to Infobox_Ship tempate for wiki
docstring_summary: Write a given <ship>.json file to Infobox_Ship tempate for wiki
docstring_tokens: Write a given <ship > . json file to Infobox_Ship tempate for wiki
function: def print_ship_as_wiki_infobox(ship_name):
      "Write a given <ship>.json file to Infobox_Ship tempate for wiki"
  
      with open(ship_name, 'r') as ship_file:
          shipTable = json.load(ship_file)
  
      try:
          if shipTable['slots']['engine'] > 0:
              max_engine = "yes"
          else:
              max_engine = "no"
      except:
          # default to 1, so if not defined, it exists:
          max_engine = "yes"
  
      # calculate effective exhaust velocity
      deltaV_empty = shipTable['effective_exhaust_velocity'] * \
                     math.log((shipTable['hull_mass'] + shipTable['fuel_tank_mass'])
                              / shipTable['hull_mass'])
  
      deltaV_full = shipTable['effective_exhaust_velocity'] * \
                    math.log((shipTable['hull_mass'] + shipTable['fuel_tank_mass'] + shipTable['capacity']) /
                             (shipTable['hull_mass'] + shipTable['capacity']))
  
  #    deltaV_empty = myround(deltaV_empty, -3) / 1000
  #    deltaV_full = myround(deltaV_full, -3) / 1000
      deltaV_empty = round(deltaV_empty/1000)
      deltaV_full = round(deltaV_full/1000)
  
      print('{{Infobox_Ship')
      print("|name = %s" % shipTable['name'])
      print("|type = %s" % get_ship_type(shipTable['ship_class']))
      sketchfab = load_sketchfab("sketchfab.json")
      model = shipTable['model']
      if model in sketchfab:
          print("|sketchfab = <sketchfab>%s</sketchfab>" % sketchfab[model])
      else:
          print("|sketchfab = ''")
      print("|manufacturer = %s" % manufacturers[shipTable['manufacturer']])
      print("|effective_exhaust_velocity_empty = %skm/s\n|effective_exhaust_velocity_full = %skm/s" % (nice_int(deltaV_empty), nice_int(deltaV_full)))
      for d in ['forward', 'reverse', 'up', 'down', 'left', 'right', 'angular']:
          thrust_n = shipTable[d + '_thrust']
          [thrust_rounded,thrust_suffix] = get_si_suffix(thrust_n)
          empty    = thrust(thrust_n, shipTable['hull_mass'], shipTable['fuel_tank_mass'])
          full     = thrust(thrust_n, shipTable['hull_mass'], shipTable['fuel_tank_mass'], shipTable['capacity'])
          print("|%s_thrust_empty = %.1fG (%.2f%sN)\n|%s_thrust_full = %.1fG" % (d, empty, thrust_rounded, thrust_suffix, d, full))
  
      print("|max_cargo = %s" % nice_int(shipTable['slots']['cargo']))
      print("|max_laser = %s" % shipTable['slots']['laser_front'])
      print("|max_missile = %s" % shipTable['slots']['missile'])
      print("|max_scoop_mounts = %s" % shipTable['slots']['scoop'])
      print("|hyperdrive_class = %s" % shipTable['hyperdrive_class'])
      print("|min_crew = %s" % shipTable['min_crew'])
      print("|max_crew = %s" % shipTable['max_crew'])
      print("|capacity = %s" % nice_int(shipTable['capacity']))
      print("|hull_mass = %s" % nice_int(shipTable['hull_mass']))
      print("|fuel_tank_mass = %s" % nice_int(shipTable['fuel_tank_mass']))
      # https://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators#10742904
      print("|price = %s" % nice_int(shipTable['price']))
      print("|max_engine = " + max_engine)
      print("}}")
function_tokens: def print_ship_as_wiki_infobox ( ship_name ) : with open ( ship_name , 'r' ) as ship_file : shipTable = json . load ( ship_file ) try : if shipTable [ 'slots' ] [ 'engine' ] > 0 : max_engine = "yes" else : max_engine = "no" except : # default to 1, so if not defined, it exists: max_engine = "yes" # calculate effective exhaust velocity deltaV_empty = shipTable [ 'effective_exhaust_velocity' ] * math . log ( ( shipTable [ 'hull_mass' ] + shipTable [ 'fuel_tank_mass' ] ) / shipTable [ 'hull_mass' ] ) deltaV_full = shipTable [ 'effective_exhaust_velocity' ] * math . log ( ( shipTable [ 'hull_mass' ] + shipTable [ 'fuel_tank_mass' ] + shipTable [ 'capacity' ] ) / ( shipTable [ 'hull_mass' ] + shipTable [ 'capacity' ] ) ) #    deltaV_empty = myround(deltaV_empty, -3) / 1000 #    deltaV_full = myround(deltaV_full, -3) / 1000 deltaV_empty = round ( deltaV_empty / 1000 ) deltaV_full = round ( deltaV_full / 1000 ) print ( '{{Infobox_Ship' ) print ( "|name = %s" % shipTable [ 'name' ] ) print ( "|type = %s" % get_ship_type ( shipTable [ 'ship_class' ] ) ) sketchfab = load_sketchfab ( "sketchfab.json" ) model = shipTable [ 'model' ] if model in sketchfab : print ( "|sketchfab = <sketchfab>%s</sketchfab>" % sketchfab [ model ] ) else : print ( "|sketchfab = ''" ) print ( "|manufacturer = %s" % manufacturers [ shipTable [ 'manufacturer' ] ] ) print ( "|effective_exhaust_velocity_empty = %skm/s\n|effective_exhaust_velocity_full = %skm/s" % ( nice_int ( deltaV_empty ) , nice_int ( deltaV_full ) ) ) for d in [ 'forward' , 'reverse' , 'up' , 'down' , 'left' , 'right' , 'angular' ] : thrust_n = shipTable [ d + '_thrust' ] [ thrust_rounded , thrust_suffix ] = get_si_suffix ( thrust_n ) empty = thrust ( thrust_n , shipTable [ 'hull_mass' ] , shipTable [ 'fuel_tank_mass' ] ) full = thrust ( thrust_n , shipTable [ 'hull_mass' ] , shipTable [ 'fuel_tank_mass' ] , shipTable [ 'capacity' ] ) print ( "|%s_thrust_empty = %.1fG (%.2f%sN)\n|%s_thrust_full = %.1fG" % ( d , empty , thrust_rounded , thrust_suffix , d , full ) ) print ( "|max_cargo = %s" % nice_int ( shipTable [ 'slots' ] [ 'cargo' ] ) ) print ( "|max_laser = %s" % shipTable [ 'slots' ] [ 'laser_front' ] ) print ( "|max_missile = %s" % shipTable [ 'slots' ] [ 'missile' ] ) print ( "|max_scoop_mounts = %s" % shipTable [ 'slots' ] [ 'scoop' ] ) print ( "|hyperdrive_class = %s" % shipTable [ 'hyperdrive_class' ] ) print ( "|min_crew = %s" % shipTable [ 'min_crew' ] ) print ( "|max_crew = %s" % shipTable [ 'max_crew' ] ) print ( "|capacity = %s" % nice_int ( shipTable [ 'capacity' ] ) ) print ( "|hull_mass = %s" % nice_int ( shipTable [ 'hull_mass' ] ) ) print ( "|fuel_tank_mass = %s" % nice_int ( shipTable [ 'fuel_tank_mass' ] ) ) # https://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators#10742904 print ( "|price = %s" % nice_int ( shipTable [ 'price' ] ) ) print ( "|max_engine = " + max_engine ) print ( "}}" )