本文整理汇总了Python中Products.CMFDefault.Document.Document.manage_FTPget方法的典型用法代码示例。如果您正苦于以下问题:Python Document.manage_FTPget方法的具体用法?Python Document.manage_FTPget怎么用?Python Document.manage_FTPget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFDefault.Document.Document
的用法示例。
在下文中一共展示了Document.manage_FTPget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSTX
# 需要导入模块: from Products.CMFDefault.Document import Document [as 别名]
# 或者: from Products.CMFDefault.Document.Document import manage_FTPget [as 别名]
def testSTX( self ):
self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT
d = Document( 'foo' )
d.PUT(self.REQUEST, self.RESPONSE)
rnlinesplit = compile( r'\r?\n?' )
get_text = d.manage_FTPget()
simple_lines = rnlinesplit.split( SIMPLE_STRUCTUREDTEXT )
get_lines = rnlinesplit.split( get_text )
# strip off headers
simple_headers = []
while simple_lines and simple_lines[0]:
simple_headers.append( simple_lines[0] )
simple_lines = simple_lines[1:]
get_headers = []
while get_lines and get_lines[0]:
get_headers.append( get_lines[0] )
get_lines = get_lines[1:]
self.assertEqual( get_lines, simple_lines )
for header in simple_headers:
self.failUnless( header in get_headers )
示例2: testHTML
# 需要导入模块: from Products.CMFDefault.Document import Document [as 别名]
# 或者: from Products.CMFDefault.Document.Document import manage_FTPget [as 别名]
def testHTML( self ):
REQUEST=fakeRequest()
REQUEST['BODY']=SIMPLE_HTML
d = Document( 'foo' )
d.PUT(REQUEST, RESPONSE=fakeResponse())
rnlinesplit = re.compile( r'\r?\n?' )
simple_lines = rnlinesplit.split( SIMPLE_HTML )
get_lines = rnlinesplit.split( d.manage_FTPget() )
# strip off headers
meta_pattern = re.compile( r'meta name="([a-z]*)" '
+ r'content="([a-z]*)"'
)
title_pattern = re.compile( r'<title>(.*)</title>' )
simple_headers = []
while simple_lines and simple_lines[0] != '<BODY>':
header = string.lower( string.strip( simple_lines[0] ) )
match = meta_pattern.search( header )
if match:
simple_headers.append( match.groups() )
else:
match = title_pattern.search( header )
if match:
simple_headers.append( ( 'title', match.group(1) ) )
simple_lines = simple_lines[1:]
get_headers = []
while get_lines and get_lines[0] != '<BODY>':
header = string.lower( string.strip( get_lines[0] ) )
match = meta_pattern.search( header )
if match:
get_headers.append( match.groups() )
else:
match = title_pattern.search( header )
if match:
get_headers.append( ( 'title', match.group(1) ) )
get_lines = get_lines[1:]
self.assertEqual( get_lines, simple_lines )
self.failUnless( get_headers )
self.failUnless( simple_headers )
self.failUnless( len( get_headers ) >= len( simple_headers ) )
for header in simple_headers:
self.failUnless( header in get_headers )
示例3: testSTX
# 需要导入模块: from Products.CMFDefault.Document import Document [as 别名]
# 或者: from Products.CMFDefault.Document.Document import manage_FTPget [as 别名]
def testSTX( self ):
REQUEST=fakeRequest()
REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT
d = Document( 'foo' )
d.PUT(REQUEST, RESPONSE=fakeResponse())
simple_lines = string.split( SIMPLE_STRUCTUREDTEXT, '\n' )
get_lines = string.split( d.manage_FTPget(), '\n' )
# strip off headers
simple_headers = []
while simple_lines and simple_lines[0]:
simple_headers.append( simple_lines[0] )
simple_lines = simple_lines[1:]
get_headers = []
while get_lines and get_lines[0]:
get_headers.append( get_lines[0] )
get_lines = get_lines[1:]
assert get_lines == simple_lines
for header in simple_headers:
assert header in get_headers, [header, get_headers]