color -> colour

Tue, 12 Dec 2017 11:50:18 +0200

author
Santeri Piippo
date
Tue, 12 Dec 2017 11:50:18 +0200
changeset 4
8eb83f200486
parent 3
1dc58f44d556
child 5
e340e35d6e4c

color -> colour

ldraw.py file | annotate | diff | comparison | revisions
linetypes.py file | annotate | diff | comparison | revisions
parse.py file | annotate | diff | comparison | revisions
--- a/ldraw.py	Mon Dec 11 00:46:35 2017 +0200
+++ b/ldraw.py	Tue Dec 12 11:50:18 2017 +0200
@@ -1,11 +1,11 @@
-class Color:
+class Colour:
     def __init__(self, index):
         self.index = int(index, 0)
     def __str__(self):
-        if self.is_direct_color():
-            # write direct colors with hex codes
+        if self.is_direct_colour():
+            # write direct colours with hex codes
             return '0x%07X' % self.index
         else:
             return str(self.index)
-    def is_direct_color(self):
+    def is_direct_colour(self):
         return self.index >= 0x2000000
--- a/linetypes.py	Mon Dec 11 00:46:35 2017 +0200
+++ b/linetypes.py	Tue Dec 12 11:50:18 2017 +0200
@@ -34,19 +34,19 @@
             return '0 // ' + self.text
 
 class SubfileReference:
-    def __init__(self, *, color, subfile_path, anchor, matrix):
-        self.color, self.subfile_path, = color, subfile_path
+    def __init__(self, *, colour, subfile_path, anchor, matrix):
+        self.colour, self.subfile_path, = colour, subfile_path
         self.anchor, self.matrix = anchor, matrix
     def __repr__(self):
         return str.format('linetypes.SubfileReference(' \
-            'color = {color!r}, ' \
+            'colour = {colour!r}, ' \
             'subfile_path = {subfile_path!r}, ' \
             'anchor = {anchor!r}, ' \
             'matrix = {matrix!r})', **self.__dict__)
     def textual_representation(self):
         args = [
             1,
-            self.color,
+            self.colour,
             *self.anchor.coordinates,
             *self.matrix.values,
             self.subfile_path,
@@ -54,18 +54,18 @@
         return ' '.join(ldraw_str(arg) for arg in args)
 
 class BasePolygon:
-    def __init__(self, *, color, geometry):
-        self.color, self.geometry = color, geometry
+    def __init__(self, *, colour, geometry):
+        self.colour, self.geometry = colour, geometry
     def __repr__(self):
         return str.format('linetypes.{typename}(' \
-            'color = {color!r}, ' \
+            'colour = {colour!r}, ' \
             'geometry = {geometry!r})',
             typename = type(self).__name__,
-            color = self.color,
+            colour = self.colour,
             geometry = self.geometry,
         )
     def base_textual_representation(self):
-        args = [self.color]
+        args = [self.colour]
         for vertex in self.geometry.vertices:
             args += vertex.coordinates
         return ' '.join(ldraw_str(arg) for arg in args)
@@ -83,13 +83,13 @@
         return '4 ' + self.base_textual_representation()
 
 class Contour(LineSegment):
-    def __init__(self, *, color, geometry, control_points):
-        super().__init__(color = color, geometry = geometry)
+    def __init__(self, *, colour, geometry, control_points):
+        super().__init__(colour = colour, geometry = geometry)
         self.control_points = control_points
         assert(len(self.control_points) == 2)
     def __repr__(self):
         return str.format('linetypes.Contour(' \
-            'color = {color!r}, ' \
+            'colour = {colour!r}, ' \
             'geometry = {geometry!r}, ' \
             'control_points = {control_points!r})', **self.__dict__)
     def textual_representation(self):
--- a/parse.py	Mon Dec 11 00:46:35 2017 +0200
+++ b/parse.py	Tue Dec 12 11:50:18 2017 +0200
@@ -1,7 +1,7 @@
 import linetypes
 import re
 from geometry import *
-from ldraw import Color
+from ldraw import Colour
 
 class BadLdrawLine(Exception):
     pass
@@ -34,19 +34,19 @@
         raise BadLdrawLine('unable to parse')
     groups = list(match.groups())
     indices = {
-        'color_index': 0,
+        'colour_index': 0,
         'anchor': slice(1, 4),
         'matrix': slice(4, 13),
         'subfile_path': 13
     }
     try:
-        color = Color(groups[indices['color_index']])
+        colour = Colour(groups[indices['colour_index']])
         vertex_values = [float(x) for x in groups[indices['anchor']]]
         matrix_values = [float(x) for x in groups[indices['matrix']]]
     except ValueError:
         raise BadLdrawLine('bad numeric values')
     return linetypes.SubfileReference(
-        color = color,
+        colour = colour,
         anchor = Vertex(*vertex_values),
         matrix = TransformationMatrix(matrix_values),
         subfile_path = groups[indices['subfile_path']]
@@ -73,35 +73,35 @@
             raise BadLdrawLine('bad numeric values')
         vertices.append(Vertex(*coordinates))
     return {
-        'color': Color(match.group(1)),
+        'colour': Colour(match.group(1)),
         'vertices': vertices,
     }
 
 def parse_ldraw_line(line):
     parse_result = generic_parse_polygon(line, type_code = 2, vertex_count = 2)
     return linetypes.LineSegment(
-        color = parse_result['color'],
+        colour = parse_result['colour'],
         geometry = LineSegment(*parse_result['vertices']),
     )
 
 def parse_ldraw_triangle(line):
     parse_result = generic_parse_polygon(line, type_code = 3, vertex_count = 3)
     return linetypes.Triangle(
-        color = parse_result['color'],
+        colour = parse_result['colour'],
         geometry = Polygon(parse_result['vertices']),
     )
 
 def parse_ldraw_quadrilateral(line):
     parse_result = generic_parse_polygon(line, type_code = 4, vertex_count = 4)
     return linetypes.Quadrilateral(
-        color = parse_result['color'],
+        colour = parse_result['colour'],
         geometry = Polygon(parse_result['vertices']),
     )
 
 def parse_ldraw_contour(line):
     parse_result = generic_parse_polygon(line, type_code = 5, vertex_count = 4)
     return linetypes.Contour(
-        color = parse_result['color'],
+        colour = parse_result['colour'],
         geometry = LineSegment(*parse_result['vertices'][0:2]),
         control_points = parse_result['vertices'][2:],
     )

mercurial