~ubuntu-branches/ubuntu/feisty/fonttools/feisty

« back to all changes in this revision

Viewing changes to MetaTools/buildTableList.py

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Fok
  • Date: 2003-11-18 00:53:59 UTC
  • Revision ID: james.westby@ubuntu.com-20031118005359-pqirsxbgdz0f0xmx
Tags: upstream-1.99+2.0b1+cvs20031014
ImportĀ upstreamĀ versionĀ 1.99+2.0b1+cvs20031014

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
import sys
 
4
import os
 
5
import glob
 
6
from fontTools.ttLib import identifierToTag
 
7
 
 
8
 
 
9
fontToolsDir = os.path.dirname(os.path.dirname(os.path.join(os.getcwd(), sys.argv[0])))
 
10
fontToolsDir= os.path.normpath(fontToolsDir)
 
11
tablesDir = os.path.join(fontToolsDir,
 
12
                "Lib", "fontTools", "ttLib", "tables")
 
13
docFile = os.path.join(fontToolsDir, "Doc", "documentation.html")
 
14
 
 
15
names = glob.glob1(tablesDir, "*.py")
 
16
 
 
17
modules = []
 
18
tables = []
 
19
for name in names:
 
20
        try:
 
21
                tag = identifierToTag(name[:-3])
 
22
        except:
 
23
                pass
 
24
        else:
 
25
                modules.append(name[:-3])
 
26
                tables.append(tag.strip())
 
27
 
 
28
modules.sort()
 
29
tables.sort()
 
30
 
 
31
 
 
32
file = open(os.path.join(tablesDir, "__init__.py"), "w")
 
33
 
 
34
file.write("# DON'T EDIT! This file is generated by MetaTools/buildTableList.py.\n")
 
35
file.write("def _moduleFinderHint():\n")
 
36
file.write('\t"""Dummy function to let modulefinder know what tables may be\n')
 
37
file.write('\tdynamically imported. Generated by MetaTools/buildTableList.py.\n')
 
38
file.write('\t"""\n')
 
39
for module in modules:
 
40
        file.write("\timport %s\n" % module)
 
41
 
 
42
file.close()
 
43
 
 
44
 
 
45
begin = "<!-- begin table list -->"
 
46
end = "<!-- end table list -->"
 
47
doc = open(docFile).read()
 
48
beginPos = doc.find(begin)
 
49
assert beginPos > 0
 
50
beginPos = beginPos + len(begin) + 1
 
51
endPos = doc.find(end)
 
52
 
 
53
doc = doc[:beginPos] + ", ".join(tables[:-1]) + " and " + tables[-1] + "\n" + doc[endPos:]
 
54
 
 
55
open(docFile, "w").write(doc)