Skip to content

Commit 2a54535

Browse files
committed
More uniform asset handling by ocrd-assets itself
1 parent d7860f5 commit 2a54535

File tree

3 files changed

+26
-37
lines changed

3 files changed

+26
-37
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,5 @@ gh-pages
117117
test/assets/kant_aufklaerung_1784
118118
test/assets/00000001.jpg
119119
test/assets/test.ocrd.zip
120+
test/assets
121+
OLD.*

Makefile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ help:
1616
@echo " deps-ubuntu Dependencies for deployment in an ubuntu/debian linux"
1717
@echo " deps-pip Install python deps via pip"
1818
@echo " assets Clone the ocrd-assets repo for sample files"
19+
@echo " assets-server Start asset server at http://localhost:5001"
1920
@echo " assets-clean Remove symlinks in test/assets"
2021
@echo " install (Re)install the tool"
2122
@echo " test-deps-pip Install test python deps via pip"
2223
@echo " test Run all unit tests"
2324
@echo " docs Build documentation"
2425
@echo " docs-clean Clean docs"
25-
@echo " asset-server Start asset server at http://localhost:5001"
2626
@echo " docker Build docker image"
2727
@echo ""
2828
@echo " Variables"
@@ -46,29 +46,36 @@ deps-ubuntu:
4646
deps-pip:
4747
$(PIP) install -r requirements.txt
4848

49+
# (Re)install the tool
50+
install:
51+
$(PIP) install .
52+
53+
#
54+
# Assets
55+
#
56+
4957
# Clone the ocrd-assets repo for sample files
50-
assets:
51-
if [ ! -e ocrd-assets ];then git clone https://github.com/OCR-D/ocrd-assets;fi
58+
assets: ocrd-assets test/assets
59+
60+
ocrd-assets:
61+
git clone https://github.com/OCR-D/ocrd-assets
62+
63+
test/assets:
5264
mkdir -p test/assets
5365
cp -r -t test/assets ocrd-assets/data/*
54-
# cd test/assets && ln -fs ../../ocrd-assets/data/* .
66+
67+
# Start asset server at http://localhost:5001
68+
assets-server:
69+
cd ocrd-assets && make start
5570

5671
# Remove symlinks in test/assets
5772
assets-clean:
5873
rm -rf test/assets
5974

60-
# (Re)install the tool
61-
install:
62-
$(PIP) install .
63-
6475
#
6576
# Tests
6677
#
6778

68-
test/assets: spec
69-
mkdir -p test/assets
70-
cp -r spec/io/example test/assets/herold
71-
7279
# Install test python deps via pip
7380
test-deps-pip:
7481
$(PIP) install -r requirements_test.txt
@@ -110,10 +117,6 @@ test-profile:
110117
$(PYTHON) -m cProfile -o profile $$(which pytest)
111118
$(PYTHON) analyze_profile.py
112119

113-
# Start asset server at http://localhost:5001
114-
asset-server:
115-
cd ocrd-assets && make start
116-
117120
#
118121
# Docker
119122
#

test/base.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1+
# pylint: disable=unused-import
2+
13
import os
24
import sys
5+
from unittest import TestCase, skip, main
36

4-
from unittest import TestCase, skip, main # pylint: disable=unused-import
5-
6-
PWD = os.path.dirname(os.path.realpath(__file__))
7-
sys.path.append(PWD + '/../ocrd')
8-
9-
class Assets(object):
10-
11-
def __init__(self, baseurl=None):
12-
if baseurl is None:
13-
baseurl = 'file://' + PWD + '/assets/'
14-
self.baseurl = baseurl
15-
16-
def url_of(self, path, baseurl=None):
17-
if baseurl is None:
18-
baseurl = self.baseurl
19-
return self.baseurl + path
20-
7+
from test.assets import assets
218

22-
_baseurl = None
23-
if 'OCRD_BASEURL' in os.environ:
24-
_baseurl = os.environ['OCRD_BASEURL']
25-
assets = Assets(baseurl=_baseurl)
9+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/../ocrd')

0 commit comments

Comments
 (0)