kopia lustrzana https://github.com/collective/icalendar
default_encoding and sequencetypes as const in __init__
rodzic
fdd6aa023e
commit
c094391bdb
|
@ -1,3 +1,6 @@
|
|||
SEQUENCE_TYPES = (list, tuple)
|
||||
DEFAULT_ENCODING = 'utf-8'
|
||||
|
||||
from icalendar.cal import (
|
||||
Calendar,
|
||||
Event,
|
||||
|
|
|
@ -21,9 +21,6 @@ from icalendar.prop import (
|
|||
)
|
||||
|
||||
|
||||
SequenceTypes = (list, tuple)
|
||||
|
||||
|
||||
######################################
|
||||
# The component factory
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@ conversion is attempted.
|
|||
"""
|
||||
import re
|
||||
import logging
|
||||
from icalendar import DEFAULT_ENCODING
|
||||
from icalendar import SEQUENCE_TYPES
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
|
||||
|
||||
logger = logging.getLogger('icalendar')
|
||||
SequenceTypes = (list, tuple)
|
||||
|
||||
|
||||
def escape_char(text):
|
||||
|
@ -105,7 +106,7 @@ def foldline(text, length=75, newline='\r\n'):
|
|||
def paramVal(val):
|
||||
"""Returns a parameter value.
|
||||
"""
|
||||
if type(val) in SequenceTypes:
|
||||
if type(val) in SEQUENCE_TYPES:
|
||||
return q_join(val)
|
||||
return dQuote(val)
|
||||
|
||||
|
@ -117,8 +118,6 @@ QUNSAFE_CHAR = re.compile('[\x00-\x08\x0a-\x1f\x7F"]')
|
|||
FOLD = re.compile('(\r?\n)+[ \t]')
|
||||
NEWLINE = re.compile(r'\r?\n')
|
||||
|
||||
DEFAULT_ENCODING = 'utf-8'
|
||||
|
||||
|
||||
def validate_token(name):
|
||||
match = NAME.findall(name)
|
||||
|
|
|
@ -48,6 +48,8 @@ from datetime import (
|
|||
tzinfo,
|
||||
)
|
||||
from dateutil.tz import tzutc
|
||||
from icalendar import SEQUENCE_TYPES
|
||||
from icalendar import DEFAULT_ENCODING
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
from icalendar.parser import (
|
||||
Parameters,
|
||||
|
@ -56,11 +58,6 @@ from icalendar.parser import (
|
|||
tzid_from_dt,
|
||||
)
|
||||
|
||||
|
||||
SequenceTypes = (list, tuple)
|
||||
|
||||
DEFAULT_ENCODING = 'utf-8'
|
||||
|
||||
DATE_PART = r'(\d+)D'
|
||||
TIME_PART = r'T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?'
|
||||
DATETIME_PART = '(?:%s)?(?:%s)?' % (DATE_PART, TIME_PART)
|
||||
|
@ -648,11 +645,10 @@ class vRecur(CaselessDict):
|
|||
self.params = Parameters()
|
||||
|
||||
def to_ical(self):
|
||||
# SequenceTypes
|
||||
result = []
|
||||
for key, vals in self.sorted_items():
|
||||
typ = self.types[key]
|
||||
if not type(vals) in SequenceTypes:
|
||||
if not type(vals) in SEQUENCE_TYPES:
|
||||
vals = [vals]
|
||||
vals = ','.join([typ(val).to_ical() for val in vals])
|
||||
result.append('%s=%s' % (key, vals))
|
||||
|
@ -685,7 +681,7 @@ class vText(unicode):
|
|||
|
||||
def __new__(cls, value, encoding=DEFAULT_ENCODING):
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode(DEFAULT_ENCODING)
|
||||
value = value.encode(encoding)
|
||||
self = super(vText, cls).__new__(cls, value, encoding=encoding)
|
||||
self.encoding = encoding
|
||||
self.params = Parameters()
|
||||
|
|
Ładowanie…
Reference in New Issue