コード例 #1
0
ファイル: adrvalue.py プロジェクト: gingerkaan/serveros
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# vCard ADR value

from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue
from pycalendar.vcard.adr import Adr


class AdrValue(WrapperValue, Value):

    _wrappedClass = Adr
    _wrappedType = Value.VALUETYPE_ADR


Value.registerType(Value.VALUETYPE_ADR, AdrValue, None)
コード例 #2
0
    def writeXML(self, node, namespace):

        os = StringIO()
        self.generate(os)
        text = os.getvalue()
        text = text[:-2] + ":" + text[-2:]

        value = self.getXMLNode(node, namespace)
        value.text = text

    def parseJSONValue(self, jobject):
        self.parse(str(jobject), variant="vcard")

    def writeJSONValue(self, jobject):

        os = StringIO()
        self.generate(os, fullISO=True)
        text = os.getvalue()
        jobject.append(text)

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_UTC_OFFSET, UTCOffsetValue,
                   xmldefinitions.value_utc_offset)
コード例 #3
0
        description = XML.SubElement(
            value,
            xmlutils.makeTag(namespace, xmldefinitions.req_status_description))
        description.text = self.mValue[1]

        if len(self.mValue) == 3 and self.mValue[2]:
            data = XML.SubElement(
                value,
                xmlutils.makeTag(namespace, xmldefinitions.req_status_data))
            data.text = self.mValue[2]

    def parseJSONValue(self, jobject):
        self.mValue = map(lambda x: x.encode("utf-8"), jobject)

    def writeJSONValue(self, jobject):
        value = [self.mValue[0], self.mValue[1]]
        if len(self.mValue) == 3:
            value.append(self.mValue[2])
        jobject.append(value)

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_REQUEST_STATUS, RequestStatusValue, None,
                   xmldefinitions_top.value_text)
コード例 #4
0
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar.icalendar import xmldefinitions
from pycalendar.icalendar.recurrence import Recurrence
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue

class RecurrenceValue(WrapperValue, Value):

    _wrappedClass = Recurrence
    _wrappedType = Value.VALUETYPE_RECUR

    def writeXML(self, node, namespace):
        self.mValue.writeXML(node, namespace)

Value.registerType(Value.VALUETYPE_RECUR, RecurrenceValue, xmldefinitions.value_recur)
コード例 #5
0
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar Unknown value - one whose default type we don't know about

from pycalendar import xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value

class UnknownValue(PlainTextValue):

    def getType(self):
        return UnknownValue.VALUETYPE_UNKNOWN

Value.registerType(Value.VALUETYPE_UNKNOWN, UnknownValue, xmldefinitions.value_unknown)
コード例 #6
0
ファイル: durationvalue.py プロジェクト: eventable/PyCalendar
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.duration import Duration
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue

class DurationValue(WrapperValue, Value):

    _wrappedClass = Duration
    _wrappedType = Value.VALUETYPE_DURATION

Value.registerType(Value.VALUETYPE_DURATION, DurationValue, xmldefinitions.value_duration)
コード例 #7
0
ファイル: orgvalue.py プロジェクト: gingerkaan/serveros
    """
    def __init__(self, value=None):
        self.mValue = value

    def duplicate(self):
        return OrgValue(self.mValue)

    def getType(self):
        return Value.VALUETYPE_ORG

    def parse(self, data, variant="vcard"):
        self.mValue = utils.parseTextList(data, ';')

    def generate(self, os):
        utils.generateTextList(os, self.mValue, ';')

    def parseJSONValue(self, jobject):
        self.mValue = tuple(map(lambda x: x.encode("utf-8"), jobject))

    def writeJSONValue(self, jobject):
        jobject.append(list(self.mValue))

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_ORG, OrgValue, None)
コード例 #8
0
ファイル: datetimevalue.py プロジェクト: eventable/PyCalendar
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.datetime import DateTime
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue

class DateTimeValue(WrapperValue, Value):

    _wrappedClass = DateTime
    _wrappedType = None # Depends on actual value

    def getType(self):
        return (Value.VALUETYPE_DATETIME, Value.VALUETYPE_DATE)[self.mValue.isDateOnly()]


    def parse(self, data, variant):
        self.mValue.parse(data, fullISO=(variant == "vcard"))


    def writeXML(self, node, namespace):
        self.mValue.writeXML(node, namespace)

Value.registerType(Value.VALUETYPE_DATE, DateTimeValue, xmldefinitions.value_date)
Value.registerType(Value.VALUETYPE_DATETIME, DateTimeValue, xmldefinitions.value_date_time)
コード例 #9
0
ファイル: orgvalue.py プロジェクト: eventable/PyCalendar
    def __init__(self, value=None):
        self.mValue = value

    def duplicate(self):
        return OrgValue(self.mValue)

    def getType(self):
        return Value.VALUETYPE_ORG

    def parse(self, data, variant="vcard"):
        self.mValue = utils.parseTextList(data, ";")

    def generate(self, os):
        utils.generateTextList(os, self.mValue, ";")

    def parseJSONValue(self, jobject):
        self.mValue = tuple(map(lambda x: x.encode("utf-8"), jobject))

    def writeJSONValue(self, jobject):
        jobject.append(list(self.mValue))

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_ORG, OrgValue, None)
コード例 #10
0
        code = XML.SubElement(value, xmlutils.makeTag(namespace, xmldefinitions.req_status_code))
        code.text = self.mValue[0]

        description = XML.SubElement(value, xmlutils.makeTag(namespace, xmldefinitions.req_status_description))
        description.text = self.mValue[1]

        if len(self.mValue) == 3 and self.mValue[2]:
            data = XML.SubElement(value, xmlutils.makeTag(namespace, xmldefinitions.req_status_data))
            data.text = self.mValue[2]


    def parseJSONValue(self, jobject):
        self.mValue = map(lambda x: x.encode("utf-8"), jobject)


    def writeJSONValue(self, jobject):
        value = [self.mValue[0], self.mValue[1]]
        if len(self.mValue) == 3:
            value.append(self.mValue[2])
        jobject.append(value)


    def getValue(self):
        return self.mValue


    def setValue(self, value):
        self.mValue = value

Value.registerType(Value.VALUETYPE_REQUEST_STATUS, RequestStatusValue, None, xmldefinitions_top.value_text)
コード例 #11
0
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar UTC Offset value

from pycalendar import xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value

class CalAddressValue(PlainTextValue):

    def getType(self):
        return Value.VALUETYPE_CALADDRESS

Value.registerType(Value.VALUETYPE_CALADDRESS, CalAddressValue, xmldefinitions.value_cal_address)
コード例 #12
0
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar.icalendar import xmldefinitions
from pycalendar.icalendar.recurrence import Recurrence
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue


class RecurrenceValue(WrapperValue, Value):

    _wrappedClass = Recurrence
    _wrappedType = Value.VALUETYPE_RECUR

    def writeXML(self, node, namespace):
        self.mValue.writeXML(node, namespace)


Value.registerType(Value.VALUETYPE_RECUR, RecurrenceValue,
                   xmldefinitions.value_recur)
コード例 #13
0
ファイル: textvalue.py プロジェクト: eventable/PyCalendar
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar UTC Offset value

from pycalendar import utils, xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value

class TextValue(PlainTextValue):

    def getType(self):
        return Value.VALUETYPE_TEXT


    def parse(self, data, variant):
        # Decoding required
        self.mValue = utils.decodeTextValue(data)


    # os - StringIO object
    def generate(self, os):
        try:
            # Encoding required
            utils.writeTextValue(os, self.mValue)
        except:
            pass

Value.registerType(Value.VALUETYPE_TEXT, TextValue, xmldefinitions.value_text)
コード例 #14
0
ファイル: multivalue.py プロジェクト: eventable/PyCalendar
    def generate(self, os):
        try:
            first = True
            for iter in self.mValues:
                if first:
                    first = False
                else:
                    os.write(",")
                iter.generate(os)
        except:
            pass


    def writeXML(self, node, namespace):
        for iter in self.mValues:
            iter.writeXML(node, namespace)


    def parseJSONValue(self, jobject):
        for jvalue in jobject:
            value = Value.createFromType(self.mType)
            value.parseJSONValue(jvalue)
            self.mValues.append(value)


    def writeJSONValue(self, jobject):
        for iter in self.mValues:
            iter.writeJSONValue(jobject)

Value.registerType(Value.VALUETYPE_MULTIVALUE, MultiValue, None)
コード例 #15
0
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar UTC Offset value

from pycalendar import xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value


class CalAddressValue(PlainTextValue):
    def getType(self):
        return Value.VALUETYPE_CALADDRESS


Value.registerType(Value.VALUETYPE_CALADDRESS, CalAddressValue,
                   xmldefinitions.value_cal_address)
コード例 #16
0
ファイル: multivalue.py プロジェクト: gingerkaan/serveros
            self.mValues.append(value)

    def generate(self, os):
        try:
            first = True
            for iter in self.mValues:
                if first:
                    first = False
                else:
                    os.write(",")
                iter.generate(os)
        except:
            pass

    def writeXML(self, node, namespace):
        for iter in self.mValues:
            iter.writeXML(node, namespace)

    def parseJSONValue(self, jobject):
        for jvalue in jobject:
            value = Value.createFromType(self.mType)
            value.parseJSONValue(jvalue)
            self.mValues.append(value)

    def writeJSONValue(self, jobject):
        for iter in self.mValues:
            iter.writeJSONValue(jobject)


Value.registerType(Value.VALUETYPE_MULTIVALUE, MultiValue, None)
コード例 #17
0
ファイル: geovalue.py プロジェクト: eventable/PyCalendar
    def generate(self, os):
        os.write("%s;%s" % (self.mValue[0], self.mValue[1],))


    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)

        latitude = XML.SubElement(value, xmlutils.makeTag(namespace, xmldefinitions.geo_latitude))
        latitude.text = self.mValue[0]

        longitude = XML.SubElement(value, xmlutils.makeTag(namespace, xmldefinitions.geo_longitude))
        longitude.text = self.mValue[1]


    def parseJSONValue(self, jobject):
        self.mValue = jobject


    def writeJSONValue(self, jobject):
        jobject.append(list(self.mValue))


    def getValue(self):
        return self.mValue


    def setValue(self, value):
        self.mValue = value

Value.registerType(Value.VALUETYPE_GEO, GeoValue, xmldefinitions.geo, xmldefinitions_top.value_float)
コード例 #18
0
ファイル: floatvalue.py プロジェクト: eventable/PyCalendar
    def parse(self, data, variant):
        self.mValue = float(data)

    # os - StringIO object
    def generate(self, os):
        try:
            os.write(str(self.mValue))
        except:
            pass

    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)
        value.text = str(self.mValue)

    def parseJSONValue(self, jobject):
        self.mValue = float(jobject)

    def writeJSONValue(self, jobject):
        jobject.append(self.mValue)

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_FLOAT, FloatValue,
                   xmldefinitions.value_float)
コード例 #19
0
ファイル: integervalue.py プロジェクト: eventable/PyCalendar
    def parse(self, data, variant):
        self.mValue = int(data)

    # os - StringIO object
    def generate(self, os):
        try:
            os.write(str(self.mValue))
        except:
            pass

    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)
        value.text = str(self.mValue)

    def parseJSONValue(self, jobject):
        self.mValue = int(jobject)

    def writeJSONValue(self, jobject):
        jobject.append(self.mValue)

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_INTEGER, IntegerValue,
                   xmldefinitions.value_integer)
コード例 #20
0
        os = StringIO()
        self.generate(os)
        text = os.getvalue()
        text = text[:-2] + ":" + text[-2:]

        value = self.getXMLNode(node, namespace)
        value.text = text


    def parseJSONValue(self, jobject):
        self.parse(str(jobject), variant="vcard")


    def writeJSONValue(self, jobject):

        os = StringIO()
        self.generate(os, fullISO=True)
        text = os.getvalue()
        jobject.append(text)


    def getValue(self):
        return self.mValue


    def setValue(self, value):
        self.mValue = value

Value.registerType(Value.VALUETYPE_UTC_OFFSET, UTCOffsetValue, xmldefinitions.value_utc_offset)
コード例 #21
0
ファイル: periodvalue.py プロジェクト: eventable/PyCalendar
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.period import Period
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue

class PeriodValue(WrapperValue, Value):

    _wrappedClass = Period
    _wrappedType = Value.VALUETYPE_PERIOD

Value.registerType(Value.VALUETYPE_PERIOD, PeriodValue, xmldefinitions.value_period)
コード例 #22
0
class URIValue(PlainTextValue):
    def getType(self):
        return URIValue.VALUETYPE_URI

    def parse(self, data, variant):

        if ParserContext.BACKSLASH_IN_URI_VALUE == ParserContext.PARSER_FIX:
            # Decoding required
            self.mValue = utils.decodeTextValue(data)
        else:
            # No decoding required
            self.mValue = data

    # os - StringIO object
    def generate(self, os):
        """
        Handle a client bug where it sometimes includes a \n in the value and we need
        to make sure that gets encoded rather than included literally which would break syntax.
        """
        if '\n' in self.mValue:
            try:
                # No encoding required
                os.write(self.mValue.replace("\n", "\\n"))
            except:
                pass
        else:
            super(URIValue, self).generate(os)


Value.registerType(Value.VALUETYPE_URI, URIValue, xmldefinitions.value_uri)
コード例 #23
0
ファイル: nvalue.py プロジェクト: eventable/PyCalendar
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# vCard N value

from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue
from pycalendar.vcard.n import N


class NValue(WrapperValue, Value):

    _wrappedClass = N
    _wrappedType = Value.VALUETYPE_N


Value.registerType(Value.VALUETYPE_N, NValue, None)
コード例 #24
0
ファイル: nvalue.py プロジェクト: eventable/PyCalendar
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# vCard N value

from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue
from pycalendar.vcard.n import N

class NValue(WrapperValue, Value):

    _wrappedClass = N
    _wrappedType = Value.VALUETYPE_N

Value.registerType(Value.VALUETYPE_N, NValue, None)
コード例 #25
0
ファイル: datetimevalue.py プロジェクト: eventable/PyCalendar
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.datetime import DateTime
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue


class DateTimeValue(WrapperValue, Value):

    _wrappedClass = DateTime
    _wrappedType = None  # Depends on actual value

    def getType(self):
        return (Value.VALUETYPE_DATETIME,
                Value.VALUETYPE_DATE)[self.mValue.isDateOnly()]

    def parse(self, data, variant):
        self.mValue.parse(data, fullISO=(variant == "vcard"))

    def writeXML(self, node, namespace):
        self.mValue.writeXML(node, namespace)


Value.registerType(Value.VALUETYPE_DATE, DateTimeValue,
                   xmldefinitions.value_date)
Value.registerType(Value.VALUETYPE_DATETIME, DateTimeValue,
                   xmldefinitions.value_date_time)
コード例 #26
0
ファイル: periodvalue.py プロジェクト: gingerkaan/serveros
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.period import Period
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue


class PeriodValue(WrapperValue, Value):

    _wrappedClass = Period
    _wrappedType = Value.VALUETYPE_PERIOD

Value.registerType(Value.VALUETYPE_PERIOD, PeriodValue, xmldefinitions.value_period)
コード例 #27
0
##
#    Copyright (c) 2011-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar Binary value

from pycalendar import xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value


class BinaryValue(PlainTextValue):
    def getType(self):
        return Value.VALUETYPE_BINARY


Value.registerType(Value.VALUETYPE_BINARY, BinaryValue,
                   xmldefinitions.value_binary)
コード例 #28
0
ファイル: floatvalue.py プロジェクト: eventable/PyCalendar
    # os - StringIO object
    def generate(self, os):
        try:
            os.write(str(self.mValue))
        except:
            pass


    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)
        value.text = str(self.mValue)


    def parseJSONValue(self, jobject):
        self.mValue = float(jobject)


    def writeJSONValue(self, jobject):
        jobject.append(self.mValue)


    def getValue(self):
        return self.mValue


    def setValue(self, value):
        self.mValue = value

Value.registerType(Value.VALUETYPE_FLOAT, FloatValue, xmldefinitions.value_float)
コード例 #29
0
ファイル: integervalue.py プロジェクト: eventable/PyCalendar
        return Value.VALUETYPE_INTEGER

    def parse(self, data, variant):
        self.mValue = int(data)

    # os - StringIO object
    def generate(self, os):
        try:
            os.write(str(self.mValue))
        except:
            pass

    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)
        value.text = str(self.mValue)

    def parseJSONValue(self, jobject):
        self.mValue = int(jobject)

    def writeJSONValue(self, jobject):
        jobject.append(self.mValue)

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_INTEGER, IntegerValue, xmldefinitions.value_integer)
コード例 #30
0
ファイル: urivalue.py プロジェクト: eventable/PyCalendar
class URIValue(PlainTextValue):
    def getType(self):
        return URIValue.VALUETYPE_URI

    def parse(self, data, variant):

        if ParserContext.BACKSLASH_IN_URI_VALUE == ParserContext.PARSER_FIX:
            # Decoding required
            self.mValue = utils.decodeTextValue(data)
        else:
            # No decoding required
            self.mValue = data

    # os - StringIO object
    def generate(self, os):
        """
        Handle a client bug where it sometimes includes a \n in the value and we need
        to make sure that gets encoded rather than included literally which would break syntax.
        """
        if "\n" in self.mValue:
            try:
                # No encoding required
                os.write(self.mValue.replace("\n", "\\n"))
            except:
                pass
        else:
            super(URIValue, self).generate(os)


Value.registerType(Value.VALUETYPE_URI, URIValue, xmldefinitions.value_uri)
コード例 #31
0
ファイル: textvalue.py プロジェクト: gingerkaan/serveros
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar UTC Offset value

from pycalendar import utils, xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value


class TextValue(PlainTextValue):
    def getType(self):
        return Value.VALUETYPE_TEXT

    def parse(self, data, variant):
        # Decoding required
        self.mValue = utils.decodeTextValue(data)

    # os - StringIO object
    def generate(self, os):
        try:
            # Encoding required
            utils.writeTextValue(os, self.mValue)
        except:
            pass


Value.registerType(Value.VALUETYPE_TEXT, TextValue, xmldefinitions.value_text)
コード例 #32
0
##
#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import xmldefinitions
from pycalendar.duration import Duration
from pycalendar.value import Value
from pycalendar.valueutils import WrapperValue


class DurationValue(WrapperValue, Value):

    _wrappedClass = Duration
    _wrappedType = Value.VALUETYPE_DURATION


Value.registerType(Value.VALUETYPE_DURATION, DurationValue,
                   xmldefinitions.value_duration)
コード例 #33
0
            self.mValue[0],
            self.mValue[1],
        ))

    def writeXML(self, node, namespace):
        value = self.getXMLNode(node, namespace)

        latitude = XML.SubElement(
            value, xmlutils.makeTag(namespace, xmldefinitions.geo_latitude))
        latitude.text = self.mValue[0]

        longitude = XML.SubElement(
            value, xmlutils.makeTag(namespace, xmldefinitions.geo_longitude))
        longitude.text = self.mValue[1]

    def parseJSONValue(self, jobject):
        self.mValue = jobject

    def writeJSONValue(self, jobject):
        jobject.append(list(self.mValue))

    def getValue(self):
        return self.mValue

    def setValue(self, value):
        self.mValue = value


Value.registerType(Value.VALUETYPE_GEO, GeoValue, xmldefinitions.geo,
                   xmldefinitions_top.value_float)
コード例 #34
0
ファイル: binaryvalue.py プロジェクト: eventable/PyCalendar
##
#    Copyright (c) 2011-2013 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

# iCalendar Binary value

from pycalendar import xmldefinitions
from pycalendar.plaintextvalue import PlainTextValue
from pycalendar.value import Value

class BinaryValue(PlainTextValue):

    def getType(self):
        return Value.VALUETYPE_BINARY

Value.registerType(Value.VALUETYPE_BINARY, BinaryValue, xmldefinitions.value_binary)