summaryrefslogtreecommitdiff
path: root/pyasn1/compat/string.py
blob: 058eb48370e140ac9e304f2c8ef0bc17a1306063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
# License: http://pyasn1.sf.net/license.html
#
from sys import version_info

if version_info[:2] <= (2, 5):

    def partition(string, sep):
        try:
            a, c = string.split(sep, 1)

        except ValueError:
            a, b, c = string, '', ''

        else:
            b = sep

        return a, b, c

else:

    def partition(string, sep):
        return string.partition(sep)