Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
81264706
Commit
81264706
authored
Nov 10, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated load_site with Oleg Broytmann's patches to parse out title and
property information.
parent
fd1b5748
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
3 deletions
+114
-3
utilities/load_site.py
utilities/load_site.py
+114
-3
No files found.
utilities/load_site.py
View file @
81264706
...
...
@@ -173,16 +173,127 @@ def upload_dir(object, f):
for
n
in
os
.
listdir
(
f
):
upload_file
(
object
,
os
.
path
.
join
(
f
,
n
))
# ----- phd -----
# Modified by Oleg Broytmann <phd2@earthling.net>
from
sgmllib
import
SGMLParser
def
join_attrs
(
attrs
):
attr_list
=
[]
for
attrname
,
value
in
attrs
:
attr_list
.
append
(
'%s="%s"'
%
(
attrname
,
string
.
strip
(
value
)))
if
attr_list
:
s
=
" "
+
string
.
join
(
attr_list
,
" "
)
else
:
s
=
""
return
s
class
HeadParser
(
SGMLParser
):
def
__init__
(
self
):
SGMLParser
.
__init__
(
self
)
self
.
seen_starthead
=
0
self
.
seen_endhead
=
0
self
.
seen_startbody
=
0
self
.
head
=
""
self
.
title
=
""
self
.
accumulator
=
""
def
handle_data
(
self
,
data
):
if
data
:
self
.
accumulator
=
self
.
accumulator
+
data
def
handle_comment
(
self
,
data
):
if
data
:
self
.
accumulator
=
self
.
accumulator
+
"<!--%s-->"
%
data
def
start_head
(
self
,
attrs
):
if
not
self
.
seen_starthead
:
self
.
seen_starthead
=
1
self
.
head
=
""
self
.
title
=
""
self
.
accumulator
=
""
def
end_head
(
self
):
if
not
self
.
seen_endhead
:
self
.
seen_endhead
=
1
self
.
head
=
self
.
head
+
self
.
accumulator
self
.
accumulator
=
""
def
start_title
(
self
,
attrs
):
self
.
head
=
self
.
head
+
self
.
accumulator
self
.
accumulator
=
""
def
end_title
(
self
):
self
.
title
=
self
.
accumulator
self
.
accumulator
=
""
def
start_body
(
self
,
attrs
):
if
not
self
.
seen_startbody
:
self
.
seen_startbody
=
1
self
.
accumulator
=
""
def
end_body
(
self
):
pass
# Do not put </BODY> and </HTML>
def
end_html
(
self
):
pass
# into output stream
# Pass other tags unmodified
def
unknown_starttag
(
self
,
tag
,
attrs
):
self
.
accumulator
=
self
.
accumulator
+
"<%s%s>"
%
(
string
.
upper
(
tag
),
join_attrs
(
attrs
))
def
unknown_endtag
(
self
,
tag
):
self
.
accumulator
=
self
.
accumulator
+
"</%s>"
%
string
.
upper
(
tag
)
def
parse_html
(
infile
):
parser
=
HeadParser
()
while
1
:
line
=
infile
.
readline
()
if
not
line
:
break
parser
.
feed
(
line
)
parser
.
close
()
infile
.
close
()
return
string
.
strip
(
parser
.
title
),
string
.
strip
(
parser
.
head
),
\
"""<!--#var standard_html_header-->
"""
+
string
.
strip
(
parser
.
accumulator
)
+
"""
<!--#var standard_html_footer-->"""
def
upload_html
(
object
,
f
):
dir
,
name
=
os
.
path
.
split
(
f
)
f
=
open
(
f
)
# There is a Document bugs that causes file uploads to fail.
# Waaa. This will be fixed in 1.10.2.
f
=
f
.
read
()
#f=f.read()
title
,
head
,
body
=
parse_html
(
f
)
if
old
:
call
(
object
.
manage_addDocument
,
id
=
name
,
file
=
f
)
call
(
object
.
manage_addDocument
,
id
=
name
,
file
=
body
)
else
:
call
(
object
.
manage_addDTMLDocument
,
id
=
name
,
file
=
f
)
call
(
object
.
manage_addDTMLDocument
,
id
=
name
,
title
=
title
,
file
=
body
)
# Now add META and other tags as property
if
head
:
object
=
object
.
__class__
(
object
.
url
+
'/'
+
name
,
username
=
object
.
username
,
password
=
object
.
password
)
call
(
object
.
manage_addProperty
,
id
=
"loadsite-head"
,
type
=
"text"
,
value
=
head
)
# ----- /phd -----
upload_htm
=
upload_html
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment