示例#1
0
 def test_relative_path(self):
     pkg = PkgResources("vumi.tests")
     self.assertEqual(os.path.join(self.vumi_tests_path, 'foo/bar'),
                      pkg.path('foo/bar'))
示例#2
0
 def test_absolute_path(self):
     pkg = PkgResources("vumi.tests")
     self.assertEqual('/foo/bar', pkg.path('/foo/bar'))
示例#3
0
 def test_relative_path(self):
     pkg = PkgResources("vumi.tests")
     self.assertEqual(os.path.join(self.vumi_tests_path, 'foo/bar'),
                      pkg.path('foo/bar'))
示例#4
0
import re

from twisted.web.template import Element, renderer, XMLFile, flattenString
from twisted.python.filepath import FilePath

from vumi.utils import PkgResources


MXIT_RESOURCES = PkgResources(__name__)


class ResponseParser(object):

    HEADER_PATTERN = r'^(.*)[\r\n]{1,2}\d?'
    ITEM_PATTERN = r'^(\d+)\. (.+)$'

    def __init__(self, content):
        header_match = re.match(self.HEADER_PATTERN, content)
        if header_match:
            [self.header] = header_match.groups()
            self.items = re.findall(self.ITEM_PATTERN, content, re.MULTILINE)
        else:
            self.header = content
            self.items = []

    @classmethod
    def parse(cls, content):
        p = cls(content)
        return p.header, p.items

示例#5
0
 def test_absolute_path(self):
     pkg = PkgResources("vumi.tests")
     self.assertEqual('/foo/bar', pkg.path('/foo/bar'))