Commit e941c02d authored by Arnaud Fontaine's avatar Arnaud Fontaine

Remove trailing whitespaces and empty lines



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43092 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bcce0fec
...@@ -104,7 +104,7 @@ class Telephone(Coordinate, Base): ...@@ -104,7 +104,7 @@ class Telephone(Coordinate, Base):
# +(0)1-11111111/111" or +(0)1-11111111/ or +(0)1-11111111 # +(0)1-11111111/111" or +(0)1-11111111/ or +(0)1-11111111
"\+\(0\)(?P<area>\d+)\-(?P<number>[\d\ ]*)(?:\/)?(?P<ext>\d+|)", "\+\(0\)(?P<area>\d+)\-(?P<number>[\d\ ]*)(?:\/)?(?P<ext>\d+|)",
# Missing Country and Area # Missing Country and Area
# +(0)-11111111/111" or +(0)-11111111/ or +(0)-11111111 # +(0)-11111111/111" or +(0)-11111111/ or +(0)-11111111
"\+\(0\)\-(?P<number>[\d\ ]*)(?:\/)?(?P<ext>\d+|)", "\+\(0\)\-(?P<number>[\d\ ]*)(?:\/)?(?P<ext>\d+|)",
...@@ -125,20 +125,20 @@ class Telephone(Coordinate, Base): ...@@ -125,20 +125,20 @@ class Telephone(Coordinate, Base):
# This regex is to handle two inputs very similar # This regex is to handle two inputs very similar
# but with different behavior # but with different behavior
# 111 11 11/111 or 111 11 11 or 111 11 11 # 111 11 11/111 or 111 11 11 or 111 11 11
# will result in {'area':'', 'number':'111 11 11', 'ext':'111 or empty'} # will result in {'area':'', 'number':'111 11 11', 'ext':'111 or empty'}
# #
# 111-11 11/111 or 111-11 11 or 111-11 11 # 111-11 11/111 or 111-11 11 or 111-11 11
# will result in {'area':'111', 'number':'11 11', 'ext':'111 or empty'} # will result in {'area':'111', 'number':'11 11', 'ext':'111 or empty'}
"^(?:0)?((?P<area>\d+)-)?(?P<number>[\d\-\ ]*)(?:\/)?(?P<ext>\d+|)$", "^(?:0)?((?P<area>\d+)-)?(?P<number>[\d\-\ ]*)(?:\/)?(?P<ext>\d+|)$",
# Area, Number, Extension* # Area, Number, Extension*
# It is a common input in France # It is a common input in France
# and in Japan but with different behavior. # and in Japan but with different behavior.
# 011-111-1111/111 or 011-111-1111/ or 011-111-1111 # 011-111-1111/111 or 011-111-1111/ or 011-111-1111
# will result in {'area':'11', 'number':'111-1111', \ # will result in {'area':'11', 'number':'111-1111', \
# 'ext':'111 or empty'} <= France # 'ext':'111 or empty'} <= France
# will result in {'area':'011', 'number':'111-1111', # will result in {'area':'011', 'number':'111-1111',
# 'ext':'111 or empty'} <= Japan # 'ext':'111 or empty'} <= Japan
# so we have here two regex: # so we have here two regex:
# To France: "^0(?P<area>\d+)-(?P<number>[\d\-\ ]*)(?:\/)?(?P<ext>\d+|)$", # To France: "^0(?P<area>\d+)-(?P<number>[\d\-\ ]*)(?:\/)?(?P<ext>\d+|)$",
...@@ -148,14 +148,14 @@ class Telephone(Coordinate, Base): ...@@ -148,14 +148,14 @@ class Telephone(Coordinate, Base):
# Area, Number, Extension* # Area, Number, Extension*
# It is a common input in France and in Japan but with different behavior. # It is a common input in France and in Japan but with different behavior.
# 011(111)1111/111 or 011(111)1111/ or 011(111)1111 # 011(111)1111/111 or 011(111)1111/ or 011(111)1111
# will result in {'area':'11', 'number':'111)1111', # will result in {'area':'11', 'number':'111)1111',
# 'ext':'111 or empty'} <= France # 'ext':'111 or empty'} <= France
# will result in {'area':'011', 'number':'111)1111', # will result in {'area':'011', 'number':'111)1111',
# 'ext':'111 or empty'} <= Japan # 'ext':'111 or empty'} <= Japan
# so we have here two regex: # so we have here two regex:
#To France: #To France:
# "^0(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$", # "^0(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$",
#To Japan: #To Japan:
# "^(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$", # "^(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$",
"^0(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$", "^0(?P<area>\d+)\((?P<number>[\d\)\(\ \-]*)(?:\/)?(?P<ext>\d+|)$",
...@@ -188,7 +188,7 @@ class Telephone(Coordinate, Base): ...@@ -188,7 +188,7 @@ class Telephone(Coordinate, Base):
# Missing country # Missing country
# 111/111-1111/111 or 111/111-1111/ or 111/111-1111 # 111/111-1111/111 or 111/111-1111/ or 111/111-1111
"(?P<area>\d+)\/(?P<number>[\d\ \-]*)(?:\/)?(?P<ext>\d+|)", "(?P<area>\d+)\/(?P<number>[\d\ \-]*)(?:\/)?(?P<ext>\d+|)",
# Country, area, number, extension* # Country, area, number, extension*
# Hyphen between country and area. # Hyphen between country and area.
# +11-1 11 11 01 11/111 or +11-1 11 11 01 11/ or +11-1 11 11 01 11 # +11-1 11 11 01 11/111 or +11-1 11 11 01 11/ or +11-1 11 11 01 11
...@@ -230,21 +230,21 @@ class Telephone(Coordinate, Base): ...@@ -230,21 +230,21 @@ class Telephone(Coordinate, Base):
# + (111) 111-111/111 or + (111) 111-111/ or + (111) 111-111 # + (111) 111-111/111 or + (111) 111-111/ or + (111) 111-111
"\+(?P<spaces>[\ ]*)\((?P<country>\d+)\)\ (?P<number>[\d\ \-\.]*)(?:\/)?(?P<ext>\d+|)" "\+(?P<spaces>[\ ]*)\((?P<country>\d+)\)\ (?P<number>[\d\ \-\.]*)(?:\/)?(?P<ext>\d+|)"
] ]
security.declareProtected(Permissions.ModifyPortalContent, 'fromText') security.declareProtected(Permissions.ModifyPortalContent, 'fromText')
def fromText(self, coordinate_text): def fromText(self, coordinate_text):
""" See ICoordinate.fromText """ """ See ICoordinate.fromText """
method = self._getTypeBasedMethod('fromText') method = self._getTypeBasedMethod('fromText')
if method is not None: if method is not None:
return method(text=coordinate_text) return method(text=coordinate_text)
if coordinate_text is None: if coordinate_text is None:
coordinate_text = '' coordinate_text = ''
# Removing the spaces of the begin and end. # Removing the spaces of the begin and end.
coordinate_text = str(coordinate_text).strip() coordinate_text = str(coordinate_text).strip()
# This regexp get the coordinate text # This regexp get the coordinate text
# and extract number and letters # and extract number and letters
input_regex_without_markup = '[0-9A-Za-z]' input_regex_without_markup = '[0-9A-Za-z]'
input_without_markup = ''.join(re.findall(input_regex_without_markup,\ input_without_markup = ''.join(re.findall(input_regex_without_markup,\
...@@ -262,7 +262,7 @@ class Telephone(Coordinate, Base): ...@@ -262,7 +262,7 @@ class Telephone(Coordinate, Base):
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
msg = "Doesn't exist a regex to handle this telephone: ", \ msg = "Doesn't exist a regex to handle this telephone: ", \
coordinate_text coordinate_text
LOG('Telephone.fromText', WARNING, msg) LOG('Telephone.fromText', WARNING, msg)
number_dict = {'number' : input_without_markup} number_dict = {'number' : input_without_markup}
else: else:
number_dict = {'number' : coordinate_text} number_dict = {'number' : coordinate_text}
...@@ -279,9 +279,10 @@ class Telephone(Coordinate, Base): ...@@ -279,9 +279,10 @@ class Telephone(Coordinate, Base):
(extension in ['', None])): (extension in ['', None])):
country = area = city = number = extension = '' country = area = city = number = extension = ''
else: else:
# Trying to get the country and area from dict, # Trying to get the country and area from dict,
# but if it fails must be get from preference # but if it fails must be get from preference
preference_tool = self.portal_preferences preference_tool = self.portal_preferences
import pdb; pdb.set_trace()
if country in ['', None]: if country in ['', None]:
country = preference_tool.getPreferredTelephoneDefaultCountryNumber('') country = preference_tool.getPreferredTelephoneDefaultCountryNumber('')
if area in ['', None]: if area in ['', None]:
...@@ -304,9 +305,9 @@ class Telephone(Coordinate, Base): ...@@ -304,9 +305,9 @@ class Telephone(Coordinate, Base):
self.edit(telephone_country = country, self.edit(telephone_country = country,
telephone_area = area, telephone_area = area,
telephone_city = city, telephone_city = city,
telephone_number = number, telephone_number = number,
telephone_extension = extension) telephone_extension = extension)
security.declareProtected(Permissions.ModifyPortalContent, '_setText') security.declareProtected(Permissions.ModifyPortalContent, '_setText')
_setText = fromText _setText = fromText
...@@ -318,20 +319,20 @@ class Telephone(Coordinate, Base): ...@@ -318,20 +319,20 @@ class Telephone(Coordinate, Base):
script = self._getTypeBasedMethod('asText') script = self._getTypeBasedMethod('asText')
if script is not None: if script is not None:
return script() return script()
country = self.getTelephoneCountry('') country = self.getTelephoneCountry('')
area = self.getTelephoneArea('') area = self.getTelephoneArea('')
city = self.getTelephoneCity('') city = self.getTelephoneCity('')
number = self.getTelephoneNumber('') number = self.getTelephoneNumber('')
extension = self.getTelephoneExtension('') extension = self.getTelephoneExtension('')
# If country, area, number, extension are blank # If country, area, number, extension are blank
# the method should to return blank. # the method should to return blank.
if ((country == '') and \ if ((country == '') and \
(area == '') and \ (area == '') and \
(city == '') and \ (city == '') and \
(number == '') and \ (number == '') and \
(extension == '')): (extension == '')):
return '' return ''
# Define the notation # Define the notation
...@@ -341,7 +342,7 @@ class Telephone(Coordinate, Base): ...@@ -341,7 +342,7 @@ class Telephone(Coordinate, Base):
notation = notation.replace('<area>',area) notation = notation.replace('<area>',area)
if city == "": if city == "":
notation = notation.replace('<city>-', '') notation = notation.replace('<city>-', '')
else: else:
notation = notation.replace('<city>',city) notation = notation.replace('<city>',city)
notation = notation.replace('<number>',number) notation = notation.replace('<number>',number)
notation = notation.replace('<ext>',extension) notation = notation.replace('<ext>',extension)
...@@ -366,7 +367,7 @@ class Telephone(Coordinate, Base): ...@@ -366,7 +367,7 @@ class Telephone(Coordinate, Base):
telephone_area = self.getTelephoneArea() telephone_area = self.getTelephoneArea()
if telephone_area is not None: if telephone_area is not None:
url_string += telephone_area url_string += telephone_area
telephone_city = self.getTelephoneCity() telephone_city = self.getTelephoneCity()
if telephone_city is not None: if telephone_city is not None:
url_string += telephone_city url_string += telephone_city
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment