Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
c3e40de3
Commit
c3e40de3
authored
Jan 16, 2013
by
Mikhail Korobov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #344 from alexrudnick/master
Two fixes for nltk.downloader
parents
95201c85
caf74a4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
nltk/downloader.py
+16
-5
No files found.
nltk/downloader.py
View file @
c3e40de3
...
@@ -183,6 +183,7 @@ from nltk import compat
...
@@ -183,6 +183,7 @@ from nltk import compat
# Directory entry objects (from the data server's index file)
# Directory entry objects (from the data server's index file)
######################################################################
######################################################################
@compat.python_2_unicode_compatible
class
Package
(
object
):
class
Package
(
object
):
"""
"""
A directory entry for a downloadable package. These entries are
A directory entry for a downloadable package. These entries are
...
@@ -254,12 +255,17 @@ class Package(object):
...
@@ -254,12 +255,17 @@ class Package(object):
def
fromxml
(
xml
):
def
fromxml
(
xml
):
if
isinstance
(
xml
,
compat
.
string_types
):
if
isinstance
(
xml
,
compat
.
string_types
):
xml
=
ElementTree
.
parse
(
xml
)
xml
=
ElementTree
.
parse
(
xml
)
for
key
in
xml
.
attrib
:
xml
.
attrib
[
key
]
=
compat
.
text_type
(
xml
.
attrib
[
key
])
return
Package
(
**
xml
.
attrib
)
return
Package
(
**
xml
.
attrib
)
def
__lt__
(
self
,
other
):
return
self
.
id
<
other
.
id
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<Package
%
s>'
%
self
.
id
return
'<Package
%
s>'
%
self
.
id
@compat.python_2_unicode_compatible
class
Collection
(
object
):
class
Collection
(
object
):
"""
"""
A directory entry for a collection of downloadable packages.
A directory entry for a collection of downloadable packages.
...
@@ -288,9 +294,14 @@ class Collection(object):
...
@@ -288,9 +294,14 @@ class Collection(object):
def
fromxml
(
xml
):
def
fromxml
(
xml
):
if
isinstance
(
xml
,
compat
.
string_types
):
if
isinstance
(
xml
,
compat
.
string_types
):
xml
=
ElementTree
.
parse
(
xml
)
xml
=
ElementTree
.
parse
(
xml
)
for
key
in
xml
.
attrib
:
xml
.
attrib
[
key
]
=
compat
.
text_type
(
xml
.
attrib
[
key
])
children
=
[
child
.
get
(
'ref'
)
for
child
in
xml
.
findall
(
'item'
)]
children
=
[
child
.
get
(
'ref'
)
for
child
in
xml
.
findall
(
'item'
)]
return
Collection
(
children
=
children
,
**
xml
.
attrib
)
return
Collection
(
children
=
children
,
**
xml
.
attrib
)
def
__lt__
(
self
,
other
):
return
self
.
id
<
other
.
id
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<Collection
%
s>'
%
self
.
id
return
'<Collection
%
s>'
%
self
.
id
...
@@ -685,12 +696,12 @@ class Downloader(object):
...
@@ -685,12 +696,12 @@ class Downloader(object):
show
(
'Downloaded collection
%
r with errors'
%
show
(
'Downloaded collection
%
r with errors'
%
msg
.
collection
.
id
)
msg
.
collection
.
id
)
else
:
else
:
show
(
'Done downloading collection
%
r
'
%
show
(
'Done downloading collection
%
s
'
%
msg
.
collection
.
id
)
msg
.
collection
.
id
)
# Package downloading messages:
# Package downloading messages:
elif
isinstance
(
msg
,
StartPackageMessage
):
elif
isinstance
(
msg
,
StartPackageMessage
):
show
(
'Downloading package
%
r
to
%
s...'
%
show
(
'Downloading package
%
s
to
%
s...'
%
(
msg
.
package
.
id
,
download_dir
))
(
msg
.
package
.
id
,
download_dir
))
elif
isinstance
(
msg
,
UpToDateMessage
):
elif
isinstance
(
msg
,
UpToDateMessage
):
show
(
'Package
%
s is already up-to-date!'
%
show
(
'Package
%
s is already up-to-date!'
%
...
@@ -1585,10 +1596,10 @@ class DownloaderGUI(object):
...
@@ -1585,10 +1596,10 @@ class DownloaderGUI(object):
self
.
_show_progress
(
None
)
self
.
_show_progress
(
None
)
return
# halt progress.
return
# halt progress.
elif
isinstance
(
msg
,
StartCollectionMessage
):
elif
isinstance
(
msg
,
StartCollectionMessage
):
show
(
'Downloading collection
%
r
'
%
msg
.
collection
.
id
)
show
(
'Downloading collection
%
s
'
%
msg
.
collection
.
id
)
self
.
_log_indent
+=
1
self
.
_log_indent
+=
1
elif
isinstance
(
msg
,
StartPackageMessage
):
elif
isinstance
(
msg
,
StartPackageMessage
):
show
(
'Downloading package
%
r
'
%
msg
.
package
.
id
)
show
(
'Downloading package
%
s
'
%
msg
.
package
.
id
)
elif
isinstance
(
msg
,
UpToDateMessage
):
elif
isinstance
(
msg
,
UpToDateMessage
):
show
(
'Package
%
s is up-to-date!'
%
msg
.
package
.
id
)
show
(
'Package
%
s is up-to-date!'
%
msg
.
package
.
id
)
#elif isinstance(msg, StaleMessage):
#elif isinstance(msg, StaleMessage):
...
...
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