Skip to content

Commit f82acb4

Browse files
authored
Merge pull request #130 from GreatBahram/master
convert ppds.normalize comments to doc-string
2 parents 83856b9 + 826292c commit f82acb4

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

cupshelpers/ppds.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,29 @@ def ppdMakeModelSplit (ppd_make_and_model):
249249
return (make, model)
250250

251251
def normalize (strin):
252-
# This function normalizes manufacturer and model names for comparing.
253-
# The string is turned to lower case and leading and trailing white
254-
# space is removed. After that each sequence of non-alphanumeric
255-
# characters (including white space) is replaced by a single space and
256-
# also at each change between letters and numbers a single space is added.
257-
# This makes the comparison only done by alphanumeric characters and the
258-
# words formed from them. So mostly two strings which sound the same when
259-
# you pronounce them are considered equal. Printer manufacturers do not
260-
# market two models whose names sound the same but differ only by
261-
# upper/lower case, spaces, dashes, ..., but in printer drivers names can
262-
# be easily supplied with these details of the name written in the wrong
263-
# way, especially if the IEEE-1284 device ID of the printer is not known.
264-
# This way we get a very reliable matching of printer model names.
265-
# Examples:
266-
# - Epson PM-A820 -> epson pm a 820
267-
# - Epson PM A820 -> epson pm a 820
268-
# - HP PhotoSmart C 8100 -> hp photosmart c 8100
269-
# - hp Photosmart C8100 -> hp photosmart c 8100
252+
"""
253+
This function normalizes manufacturer and model names for comparing.
254+
The string is turned to lower case and leading and trailing white
255+
space is removed. After that each sequence of non-alphanumeric
256+
characters (including white space) is replaced by a single space and
257+
also at each change between letters and numbers a single space is added.
258+
This makes the comparison only done by alphanumeric characters and the
259+
words formed from them. So mostly two strings which sound the same when
260+
you pronounce them are considered equal. Printer manufacturers do not
261+
market two models whose names sound the same but differ only by
262+
upper/lower case, spaces, dashes, ..., but in printer drivers names can
263+
be easily supplied with these details of the name written in the wrong
264+
way, especially if the IEEE-1284 device ID of the printer is not known.
265+
This way we get a very reliable matching of printer model names.
266+
Examples:
267+
- Epson PM-A820 -> epson pm a 820
268+
- Epson PM A820 -> epson pm a 820
269+
- HP PhotoSmart C 8100 -> hp photosmart c 8100
270+
- hp Photosmart C8100 -> hp photosmart c 8100
271+
272+
@type strin: string that can be the make or the model
273+
@return: a normalized lowercase string in which punctuations have been replaced with spaces.
274+
"""
270275
lstrin = strin.strip ().lower ()
271276
normalized = ""
272277

0 commit comments

Comments
 (0)