/usr/lib/python2.7/dist-packages/nototools/spreadsheet.py is in python-nototools 0~20170925-1.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | #!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Get information from the status spreadsheet with MTI"""
SPREADSHEET_NAME = ('Noto Project Status (Phase II)- go-noto - '
'Unicode-Monotype (1).csv')
import argparse
import csv
import os
from os import path
import re
from fontTools import ttLib
from nototools import font_data
from nototools import noto_fonts
def check_spreadsheet(src_file):
filenames = set()
prev_script_name = None
fontdata = {}
filedata = {}
with open(src_file) as csvfile:
reader = csv.DictReader(csvfile)
for index, row in enumerate(reader):
font = row['Fonts'].replace('\xc2\xa0', ' ').strip()
hinting = row['Hinting'].strip()
status = row['Status'].strip()
accepted_version = row['Accepted Version'].strip()
note = row['Note'].strip()
# family script style (variant UI) weight, mostly
m = re.match(
r'Noto (Kufi|Naskh|Color Emoji|Emoji|Sans|Serif|Nastaliq)'
r'(?: (.*?))?'
r'(?: (UI))?'
r' (Thin|Light|DemiLight|Regular|Medium|Bold Italic'
r'|Bold|Black|Italic)(?: \(merged\))?$',
font)
if not m:
m = re.match(r'Noto (Sans) (Myanmar) (UI)(.*)', font)
if not m:
print 'could not parse Myanmar exception: "%s"' % font
continue
style, script, ui, weight = m.groups()
weight = weight or 'Regular'
weight = weight.replace(' ', '')
ui = ui or ''
script = script or ''
script = re.sub('-| ', '', script)
style = style.replace(' ', '')
ext = 'ttf'
if script == 'CJK':
ext = 'ttc'
elif script.startswith('TTC'):
ext = 'ttc'
script = ''
elif script == '(LGC)':
script = ''
elif script == 'UI':
ui = 'UI'
script = ''
elif script == 'Phagspa':
script = 'PhagsPa'
elif script == 'SumeroAkkadianCuneiform':
script = 'Cuneiform'
fontname = ''.join(['Noto', style, script, ui, '-', weight, '.', ext])
# print '%s:\n--> %s\n--> %s' % (
# font, str((style, script, ui, weight)), fontname)
if not hinting in [
'hinted',
'hinted (CFF)',
'unhinted']:
print 'unrecognized hinting value \'%s\' on line %d (%s)' % (
hinting, index, fontname)
continue
hinted = 'hinted' if hinting in ['hinted', 'hinted (CFF)'] else 'unhinted'
if not status in [
'In finishing',
'Released w. lint errors',
'Approved & Released',
'Approved & Not Released',
'In design',
'Design approved',
'Design re-approved',
'Released']:
print 'unrecognized status value \'%s\' on line %d (%s)' % (
status, index, fontname)
continue
expect_font = status in [
'Released w. lint errors',
'Approved & Released',
'Approved & Not Released',
'Released']
data = (fontname, (index, font, style, script, ui, weight), hinted,
status, accepted_version, note, expect_font)
filedata[hinted + '/' + fontname] = data
# ok, now let's see if we can find these files
all_noto = noto_fonts.get_noto_fonts()
notodata = {
('hinted' if f.is_hinted else 'unhinted') +
'/' + path.basename(f.filepath) : f
for f in all_noto
}
noto_filenames = frozenset(notodata.keys())
spreadsheet_filenames = frozenset(k for k in filedata if filedata[k][6])
spreadsheet_extra = spreadsheet_filenames - noto_filenames
spreadsheet_missing = noto_filenames - spreadsheet_filenames
if spreadsheet_extra:
print 'spreadsheet extra:\n ' + '\n '.join(
sorted(spreadsheet_extra))
if spreadsheet_missing:
print 'spreadsheet missing:\n ' + '\n '.join(
sorted(spreadsheet_missing))
spreadsheet_match = spreadsheet_filenames & noto_filenames
for filename in sorted(spreadsheet_match):
data = filedata[filename]
filepath = notodata[filename].filepath
ttfont = ttLib.TTFont(filepath, fontNumber=0)
font_version = font_data.printable_font_revision(ttfont)
approved_version = data[4]
if approved_version:
warn = '!!!' if approved_version != font_version else ''
print '%s%s version: %s approved: %s' % (
warn, filename, font_version, approved_version)
else:
print '%s version: %s' % (filename, font_version)
def main():
default_file = path.expanduser(path.join('~/Downloads', SPREADSHEET_NAME))
parser = argparse.ArgumentParser()
parser.add_argument('-sf',
'--src_file',
help='path to tracking spreadsheet csv',
metavar='fname',
default=default_file)
args = parser.parse_args()
check_spreadsheet(args.src_file)
if __name__ == '__main__':
main()
|