Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion caseconverter/boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, join_char=""):
self._join_char = join_char

def is_boundary(self, pc, c):
return pc != None and pc.isalpha() and pc.isupper() and c.isupper()
return pc is not None and pc.isalpha() and pc.isupper() and c.isupper()

def handle(self, pc, cc, input_buffer, output_buffer):
output_buffer.write(cc)
13 changes: 11 additions & 2 deletions caseconverter/pascal.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from .caseconverter import CaseConverter
from .boundaries import (
BoundaryHandler,
OnDelimeterUppercaseNext,
OnUpperPrecededByLowerAppendUpper,
OnUpperPrecededByUpperAppendCurrent,
)

class OnFirstCharUpper(BoundaryHandler):
"""Boundary handler that ensures the first character is uppercase."""

def is_boundary(self, pc, c):
return pc is None

def handle(self, pc, cc, input_buffer, output_buffer):
output_buffer.write(cc.upper())


class Pascal(CaseConverter):
def init(self, input_buffer, output_buffer):
output_buffer.write(input_buffer.read(1).upper())

def define_boundaries(self):
self.add_boundary_handler(OnFirstCharUpper())
self.add_boundary_handler(OnDelimeterUppercaseNext(self.delimiters()))
self.add_boundary_handler(OnUpperPrecededByLowerAppendUpper())
self.add_boundary_handler(OnUpperPrecededByUpperAppendCurrent())
Expand Down
1 change: 1 addition & 0 deletions caseconverter/pascal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Alternating character cases
("heLlo WoRld", "HeLloWoRld"),
("helloWORLD", "HelloWORLD"),
("HELLOWorld", "HELLOWorld"),
],
)
def test_pascal_with_default_args(input, output):
Expand Down