summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2012-02-12 14:53:52 +0100
committerFlorian Bruhin <me@the-compiler.org>2012-02-12 14:53:52 +0100
commit8ef57566f767890a3dd3619efc7774cea38e09c3 (patch)
tree35df6ea9121e486ae56f68285461f0d12571159d
parentdcb6060bae34f3c162c900f4f591717806fd05ac (diff)
downloadwebopac-8ef57566f767890a3dd3619efc7774cea38e09c3.tar.gz
webopac-8ef57566f767890a3dd3619efc7774cea38e09c3.zip
Exit if there is no data
-rw-r--r--webopac.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/webopac.py b/webopac.py
index b153b9f..48b2392 100644
--- a/webopac.py
+++ b/webopac.py
@@ -7,6 +7,7 @@ import csv
import logging
import optparse
import io
+import sys
def get_webopac_data(query, baseurl):
cj = http.cookiejar.CookieJar()
@@ -68,8 +69,6 @@ def init():
return (options, args)
def printdata(data):
- data = (elem for elem in data if ' # CD_' in elem['Signatur'])
-
for row in data:
formatdict={
'title': row['Titel'],
@@ -84,7 +83,12 @@ def main():
(options, args) = init()
f = get_webopac_data(args[0], baseurl=options.baseurl)
data = decode_csv(f)
- printdata(data)
+ data = (elem for elem in data if ' # CD_' in elem['Signatur'])
+ data = list(data)
+ if data:
+ printdata(data)
+ else:
+ sys.exit(1)
if __name__ == '__main__':
main()