Remove old examples
This commit is contained in:
parent
585ef14b01
commit
ce9a15be74
@ -1,8 +0,0 @@
|
||||
from resync.resource_list import ResourceList
|
||||
from resync.resource import Resource
|
||||
from resync.sitemap import Sitemap
|
||||
|
||||
rl = ResourceList()
|
||||
rl.add( Resource('http://example.com/res1', lastmod='2013-01-01') )
|
||||
rl.add( Resource('http://example.com/res2', lastmod='2013-01-02') )
|
||||
print rl.as_xml(pretty_xml=True)
|
||||
@ -1,190 +0,0 @@
|
||||
from resync.resource_list import ResourceList
|
||||
from resync.change_list import ChangeList
|
||||
from resync.resource_dump import ResourceDump
|
||||
from resync.resource_dump_manifest import ResourceDumpManifest
|
||||
from resync.capability_list import CapabilityList
|
||||
from resync.resource import Resource
|
||||
from resync.sitemap import Sitemap
|
||||
|
||||
def head(txt):
|
||||
print "\n=== "+txt+" ===\n"
|
||||
|
||||
print "\nExample script to build objects to write the examples in the spec\n"
|
||||
|
||||
head("Example 2.1: A Resource List")
|
||||
rl = ResourceList()
|
||||
rl.modified='2013-01-03T09:00:00Z'
|
||||
rl.add( Resource('http://example.com/res1') )
|
||||
rl.add( Resource('http://example.com/res2') )
|
||||
print rl.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.2: A Resource List with additional information")
|
||||
rl = ResourceList()
|
||||
rl.modified='2013-01-03T09:00:00Z'
|
||||
rl.add( Resource('http://example.com/res1',
|
||||
lastmod='2013-01-02T13:00:00Z',
|
||||
md5='1584abdf8ebdc9802ac0c6a7402c03b') )
|
||||
rl.add( Resource('http://example.com/res2',
|
||||
lastmod='2013-01-02T14:00:00Z',
|
||||
md5='1e0d5cb8ef6ba40c99b14c0237be735e') )
|
||||
print rl.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.3: A Change List")
|
||||
cl = ChangeList()
|
||||
cl.modified="2013-01-03T11:00:00Z"
|
||||
cl.add( Resource('http://example.com/res2.pdf',
|
||||
lastmod='2013-01-02T13:00:00Z',
|
||||
change='updated') )
|
||||
cl.add( Resource('http://example.com/res3.tiff',
|
||||
lastmod='2013-01-02T18:00:00Z',
|
||||
change='deleted') )
|
||||
print cl.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.4: A Resource Dump")
|
||||
rd = ResourceDump()
|
||||
rd.modified="2013-01-03T09:00:00Z"
|
||||
rd.add( Resource('http://example.com/resourcedump.zip',
|
||||
lastmod='2013-01-03T09:00:00Z') )
|
||||
print rd.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.5: A Resource Dump Manifest detailing the content of a ZIP file")
|
||||
rdm = ResourceDumpManifest()
|
||||
rdm.modified="2013-01-03T09:00:00Z"
|
||||
rdm.add( Resource('http://example.com/res1',
|
||||
lastmod='2013-01-02T13:00:00Z',
|
||||
md5='1584abdf8ebdc9802ac0c6a7402c03b6',
|
||||
path='/resources/res1') )
|
||||
rdm.add( Resource('http://example.com/res2',
|
||||
lastmod='2013-01-02T14:00:00Z',
|
||||
md5='1e0d5cb8ef6ba40c99b14c0237be735e',
|
||||
path='/resources/res2') )
|
||||
print rdm.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.6: A Capability List with the description of the ResourceSync capabilities of a Source")
|
||||
caplist=CapabilityList()
|
||||
caplist.modified="2013-01-02T14:00:00Z"
|
||||
caplist.ln.append({'href':"http://example.com/info-about-source.xml",
|
||||
'rel':"describedby",
|
||||
'type':"application/xml"})
|
||||
caplist.add( Resource('http://example.com/dataset1/resourcelist.xml',
|
||||
capability="resourcelist") )
|
||||
caplist.add( Resource('http://example.com/dataset1/resourcedump.xml',
|
||||
capability="resourcedump") )
|
||||
caplist.add( Resource('http://example.com/dataset1/changelist.xml',
|
||||
capability="changelist") )
|
||||
print caplist.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 2.7: A Resource List Index expressed using the <sitemapindex> document format")
|
||||
rl = ResourceList()
|
||||
rl.modified="2013-01-03T09:00:00Z"
|
||||
rl.add( Resource("http://example.com/resourcelist-part2.xml",
|
||||
lastmod="2013-01-03T09:00:00Z") )
|
||||
rl.add( Resource("http://example.com/resourcelist-part1.xml",
|
||||
lastmod="2013-01-03T09:00:00Z") )
|
||||
print rl.index_as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 4.1: A Resource List")
|
||||
rl = ResourceList()
|
||||
rl.modified="2013-01-03T09:00:00Z"
|
||||
rl.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rl.add( Resource("http://example.com/res1",
|
||||
lastmod="2013-01-02T13:00:00Z",
|
||||
md5="1584abdf8ebdc9802ac0c6a7402c03b6",
|
||||
length="8876",
|
||||
type="text/html") )
|
||||
rl.add( Resource("http://example.com/res2",
|
||||
lastmod="2013-01-02T14:00:00Z",
|
||||
md5="1e0d5cb8ef6ba40c99b14c0237be735e",
|
||||
sha256="854f61290e2e197a11bc91063afce22e43f8ccc655237050ace766adc68dc784",
|
||||
length="14599",
|
||||
type="application/pdf") )
|
||||
print rl.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 4.2: A Resource List Index")
|
||||
rl = ResourceList()
|
||||
rl.modified="2013-01-03T09:00:00Z"
|
||||
rl.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rl.add( Resource("http://example.com/resourcelist3.xml",
|
||||
lastmod="2013-01-03T09:00:00Z") )
|
||||
rl.add( Resource("http://example.com/resourcelist2.xml",
|
||||
lastmod="2013-01-03T09:00:00Z") )
|
||||
rl.add( Resource("http://example.com/resourcelist1.xml",
|
||||
lastmod="2013-01-03T09:00:00Z") )
|
||||
print rl.index_as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 4.3: A Resource List with a navigational link to its parent Resource List Index")
|
||||
rl = ResourceList()
|
||||
rl.modified="2013-01-03T09:00:00Z"
|
||||
rl.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rl.ln.append({"rel":"up",
|
||||
"href":"http://example.com/dataset1/resourcelist-index.xml"})
|
||||
rl.add( Resource("http://example.com/res3",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
md5="1584abdf8ebdc9802ac0c6a7402c8753",
|
||||
length="4385",
|
||||
type="application/pdf") )
|
||||
rl.add( Resource("http://example.com/res2",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
md5="4556abdf8ebdc9802ac0c6a7402c9881",
|
||||
length="883",
|
||||
type="image/png") )
|
||||
print rl.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 5.1: A Resource Dump document")
|
||||
rd = ResourceDump()
|
||||
rd.modified = "2013-01-03T09:00:00Z"
|
||||
rd.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rd.add( Resource("http://example.com/resourcedump-part3.zip",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
type="application/zip",
|
||||
length="4765") )
|
||||
rd.add( Resource("http://example.com/resourcedump-part2.zip",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
type="application/zip",
|
||||
length="9875") )
|
||||
rd.add( Resource("http://example.com/resourcedump-part1.zip",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
type="application/zip",
|
||||
length="2298") )
|
||||
print rd.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 5.2: A Resource Dump Manifest")
|
||||
rdm = ResourceDumpManifest()
|
||||
rdm.modified="2013-01-03T09:00:00Z"
|
||||
rdm.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rdm.add( Resource("http://example.com/res1",
|
||||
lastmod="2013-01-02T13:00:00Z",
|
||||
md5="1584abdf8ebdc9802ac0c6a7402c03b6",
|
||||
length="8876",
|
||||
type="text/html",
|
||||
path="/resources/res1") )
|
||||
rdm.add( Resource("http://example.com/res2",
|
||||
lastmod="2013-01-02T14:00:00Z",
|
||||
md5="1e0d5cb8ef6ba40c99b14c0237be735e",
|
||||
sha256="854f61290e2e197a11bc91063afce22e43f8ccc655237050ace766adc68dc784",
|
||||
length="14599",
|
||||
type="application/pdf",
|
||||
path="/resources/res2") )
|
||||
print rdm.as_xml(pretty_xml=True)
|
||||
|
||||
head("Example 5.3: A Resource Dump Manifest Index")
|
||||
rdm = ResourceDumpManifest()
|
||||
rdm.modified="2013-01-03T09:00:00Z"
|
||||
rdm.ln.append({"rel":"resourcesync",
|
||||
"href":"http://example.com/dataset1/capabilitylist.xml"})
|
||||
rdm.add( Resource("/manifests/part3.xml",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
path="/manifests/part3.xml") )
|
||||
rdm.add( Resource("/manifests/part2.xml",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
path="/manifests/part2.xml") )
|
||||
rdm.add( Resource("/manifests/part1.xml",
|
||||
lastmod="2013-01-03T09:00:00Z",
|
||||
path="/manifests/part1.xml") )
|
||||
print rdm.index_as_xml(pretty_xml=True)
|
||||
|
||||
@ -6,34 +6,34 @@ resync is at <https://pypi.python.org/pypi/resync> on pypi
|
||||
|
||||
## Putting up a new version
|
||||
|
||||
0. In `develop` branch: bump version number in `resync/_version.py` and check `CHANGES.md` is up to date
|
||||
0. In `develop` branch: bump version number in `resync/__init__.py` and check `CHANGES.md` is up to date
|
||||
1. Check all tests good with appropriate Python 3.x (`python setup.py test` and CI)
|
||||
2. Check code is up-to-date with github version
|
||||
3. Check out `master` and merge in `develop`
|
||||
4. Check all tests still good (`python setup.py test` and CI)
|
||||
5. Make sure master `README.md` has correct travis-ci icon link
|
||||
6. Check branches as expected (`git branch -a`)
|
||||
7. Check local build and version reported OK (`python setup.py build; python setup.py install; resync.py --version`)
|
||||
7. Check local build and version reported OK (`python setup.py build; python setup.py install; resync-sync --version`)
|
||||
8. Check client works with simulator:
|
||||
|
||||
```
|
||||
simeon@RottenApple resync>resync.py --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: NOT IN SYNC (same=92, to create=0, to update=1, to delete=0)
|
||||
Will GET 1 resources, and delete 0 resources
|
||||
Status: SYNCED (same=92, created=0, updated=1, deleted=0)
|
||||
simeon@RottenApple resync>resync.py -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: NO CHANGES (created=0, updated=0, deleted=0)
|
||||
simeon@RottenApple resync>resync -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: CHANGES (created=1, updated=0, deleted=0)
|
||||
simeon@RottenApple resync>resync.py -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: NO CHANGES (created=0, updated=0, deleted=0)
|
||||
simeon@RottenApple resync>resync.py -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: IN SYNC (same=94, to create=0, to update=0, to delete=0)
|
||||
simeon@RottenApple resync>resync.py -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: NOT IN SYNC (same=94, to create=1, to update=0, to delete=0)
|
||||
simeon@RottenApple resync>resync.py -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -i --delete --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: CHANGES (created=1, updated=0, deleted=0)
|
||||
simeon@RottenApple resync>resync.py -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
simeon@RottenApple resync>resync-sync -a --capabilitylist=http://resync.library.cornell.edu/sim100/capabilitylist.xml http://resync.library.cornell.edu/sim100
|
||||
Status: IN SYNC (same=95, to create=0, to update=0, to delete=0)
|
||||
```
|
||||
|
||||
@ -42,11 +42,11 @@ resync is at <https://pypi.python.org/pypi/resync> on pypi
|
||||
```
|
||||
git tag -n1
|
||||
#...current tags
|
||||
git tag -a -m "ResourceSync v1.0 specification, add --delay" v2.0.0
|
||||
git tag -a -m "ResourceSync v1.1 specification, add --delay" v2.0.0
|
||||
git push --tags
|
||||
|
||||
python setup.py sdist upload
|
||||
```
|
||||
|
||||
10. Then check on PyPI at <https://pypi.python.org/pypi/resync>
|
||||
11. Finally, back on `develop` branch start new version number by editing `resync/_version.py` and `CHANGES.md`
|
||||
11. Finally, back on `develop` branch start new version number by editing `resync/__init__.py` and `CHANGES.md`
|
||||
|
||||
@ -1,45 +1,47 @@
|
||||
============================================
|
||||
ResourceSync tutorial exercises using resync
|
||||
============================================
|
||||
|
||||
# ResourceSync tutorial exercises using resync
|
||||
|
||||
Writing a Resource Dump
|
||||
-----------------------
|
||||
## Writing a Resource Dump
|
||||
|
||||
Relative to the base directory of the github distribution there is a directory
|
||||
`resync/test/testdata/dir1` with two files, `file_a` and `file_b`. We can create
|
||||
`tests/testdata/dir1` with two files, `file_a` and `file_b`. We can create
|
||||
a Resource Dump of this directory, as if it were mapped to `http://example.com/dir1`,
|
||||
with the following:
|
||||
|
||||
```
|
||||
simeon@RottenApple resync>resync --resourcedump --outfile /tmp/rd.zip http://example.com/dir1 resync/test/testdata/dir1
|
||||
resync> ./resync-build -v --write-resourcedump --outfile /tmp/rd http://example.com/dir1 tests/testdata/dir1
|
||||
Scanning disk from tests/testdata/dir1
|
||||
Writing resource dump to True...
|
||||
Total size of files to include in dump 65 bytes
|
||||
Wrote ZIP file dump /tmp/rd.zip with size 595 bytes
|
||||
|
||||
simeon@RottenApple resync>zipinfo /tmp/rd.zip
|
||||
Archive: /tmp/rd.zip
|
||||
Zip file size: 595 bytes, number of entries: 3
|
||||
?rw------- 2.0 unx 409 b- defN 13-May-28 18:40 manifest.xml
|
||||
Writing sitemap /tmp/rd00000.xml...
|
||||
Wrote sitemap /tmp/rd00000.xml
|
||||
Wrote ZIP file dump /tmp/rd00000.zip with size 623 bytes
|
||||
Wrote 1 dump files
|
||||
resync> zipinfo /tmp/rd00000.zip
|
||||
Archive: /tmp/rd00000.zip
|
||||
Zip file size: 623 bytes, number of entries: 3
|
||||
?rw------- 2.0 unx 453 b- defN 20-Dec-16 10:58 manifest.xml
|
||||
-rw-r--r-- 2.0 unx 20 b- defN 12-Jul-25 13:13 file_a
|
||||
-rw-r--r-- 2.0 unx 45 b- defN 01-Sep-08 21:46 file_b
|
||||
3 files, 474 bytes uncompressed, 297 bytes compressed: 37.3%
|
||||
3 files, 518 bytes uncompressed, 325 bytes compressed: 37.3%
|
||||
```
|
||||
|
||||
This can then be unpacked and the files checked:
|
||||
|
||||
```
|
||||
simeon@RottenApple resync>mkdir /tmp/rd
|
||||
simeon@RottenApple resync>cd /tmp/rd
|
||||
simeon@RottenApple rd>unzip ../rd.zip
|
||||
Archive: ../rd.zip
|
||||
resync> mkdir /tmp/rd
|
||||
mkdir: /tmp/rd: File exists
|
||||
resync> cd /tmp/rd
|
||||
rd> unzip ../rd00000.zip
|
||||
Archive: ../rd00000.zip
|
||||
inflating: manifest.xml
|
||||
inflating: file_a
|
||||
inflating: file_b
|
||||
simeon@RottenApple rd>more manifest.xml
|
||||
<?xml version=`1.0` encoding=`UTF-8`?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/"><url><loc>http://example.com/dir1/file_a</loc><lastmod>2012-07-25T17:13:46Z</lastmod><rs:md length="20" path="file_a" /></url><url><loc>http://example.com/dir1/file_b</loc><lastmod>2001-09-09T01:46:40Z</lastmod><rs:md length="45" path="file_b" /></url></urlset>
|
||||
simeon@RottenApple rd>more file_a
|
||||
rd> more manifest.xml
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/"><rs:md capability="resourcedump-manifest" /><url><loc>http://example.com/dir1/file_a</loc><lastmod>2012-07-25T17:13:46Z</lastmod><rs:md length="20" path="file_a" /></url><url><loc>http://example.com/dir1/file_b</loc><lastmod>2001-09-09T01:46:40Z</lastmod><rs:md length="45" path="file_b" /></url></urlset>
|
||||
rd> more file_a
|
||||
I am file a in dir1
|
||||
simeon@RottenApple rd>more file_b
|
||||
rd> more file_b
|
||||
I am file b in dir1, I am bigger than file_a
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user