This file is indexed.

/usr/share/pyshared/soya/ark2soya.py is in python-soya 0.15~rc1-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
# -*- indent-tabs-mode: t -*-

# Soya 3D
# Copyright (C) 2005 Jean-Baptiste LAMY -- jiba@tuxfamily.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Ark .3d => Soya file converter.
# see http://arkhart.nekeme.net

import os, os.path, re
import soya

def parse_ark(ark):
	ark = re.sub(r"--.*\n", "", ark)
	
	list_re = r"\{\s*n\s*=\s*(\d+)\s*,([^\{\}]*)\}"
	def list_repl(match):
		return "[%s]" % match.group(2)
	
	dict_re = r"\{((?!\s*n\s*=)[^\{\}]*)\}"
	def dict_repl(match):
		return "(%s)" % match.group(1)

	while 1:
		n = re.sub(list_re, list_repl, ark)
		n = re.sub(dict_re, dict_repl, n)

		if n == ark: break
		ark = n
		
		
	ark = "{%s}" % ark.replace("=", ":").replace(";", ",").replace("(", "{").replace(")", "}")

	ark = eval(ark, dict([(a, a) for a in [
		"Model",
		"Triangles",
		"SubModels",
		"Meshes",
		"Type",
		"Indices",
		"Material",
		"VertexCount",
		"Normals",
		"Positions",
		"TexCoords0",
		"Materials",
		"Name",
		"CollisionModel",
		]]))
	ark = ark["Model"]["SubModels"]

	model = soya.World()
	for submodel in ark:
		vertices = [
			soya.Vertex(model,
						 submodel["Positions" ][3 * i], submodel["Positions" ][3 * i + 1], submodel["Positions"][3 * i + 2],
						 submodel["TexCoords0"][2 * i], submodel["TexCoords0"][2 * i + 1],
						 )
			for i in range(submodel["VertexCount"])
			]
		
		for mesh in submodel["Meshes"]:
			if   mesh["Type"] == "Triangles": nbv = 3
			elif mesh["Type"] == "Quad"     : nbv = 4
			else: raise ValueError("UnknownVertexNumber")
			
			material = soya.Material.get(mesh["Material"])
			
			indices = mesh["Indices"][:]
			while indices:
				face_vertices = [
					vertices[indices.pop(0)]
					for i in range(nbv)
					]
				face_vertices.reverse()
				face = soya.Face(model, face_vertices, material)
				face.smooth_lit = 1
				if mesh["Material"] == "arbre_feuille_pompon": face.double_sided = 1
				
	return model


def convert_ark(name, new_name = None):
	model = parse_ark(open(os.path.join(soya.path[0], "ark", name + ".3d")).read())
	
	model.filename = new_name or name
	model.save()
	return model