<commit_before>SITE_PACKAGES = $(shell .build/venv/bin/python -c "import distutils; print(distutils.sysconfig.get_python_lib())" 2> /dev/null)
PYTHON_VERSION = $(shell .build/venv/bin/python -c "import sys; print('%i.%i' % (sys.version_info.major, sys.version_info.minor))" 2> /dev/null)
OL_JS_FILES = $(shell find node_modules/openlayers/src/ol -type f -name '*.js' 2> /dev/null)
NGEO_JS_FILES = $(shell find node_modules/ngeo/src -type f -name '*.js' 2> /dev/null)
APP_JS_FILES = $(shell find geoportailv3/static/js -type f -name '*.js')
APP_HTML_FILES = $(shell find geoportailv3/templates -type f -name '*.html')
APP_PYTHON_FILES = $(shell find geoportailv3/ -type f -name '*.py')
APP_SERVER_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3.po')
APP_CLIENT_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3-client.po')
APP_DB_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3-db.po')
LESS_FILES = $(shell find less -type f -name '*.less')
TEMPLATE_EXCLUDE += buildout .build CONST_alembic/script.py.mako print/templates/print.mako
FIND_OPTS = $(foreach ELEM, $(TEMPLATE_EXCLUDE),-path ./$(ELEM) -prune -o) -type f
TEMPLATE_FILES = $(shell find $(FIND_OPTS) -name "*.in" -print 2> /dev/null)
MAKO_FILES = $(shell find $(FIND_OPTS) -name "*.mako" -print 2> /dev/null)
JINJA_FILES = $(shell find $(FIND_OPTS) -name "*.jinja" -print 2> /dev/null)
VARS_FILES += CONST_vars.yaml
CONFIG_VARS += authtkt_cookie_name authtkt_secret sqlalchemy.url auth_replication_enabled \
	sqlalchemy_replication.url schema parentschema enable_admin_interface pyramid_closure.roots \
	pyramid_closure.roots_with_prefix node_modules_path closure_library_path default_locale_name \
	available_locale_names cache admin_interface functionalities external_themes_url \
	external_mapserv_url raster shortener mapserv_url hide_capabilities use_security_metadata \
	print_url tiles_url checker check_collector wfs default_max_age servers
ENVIRONMENT_VARS += INSTANCE_ID=${INSTANCE_ID}
C2C_TEMPLATE_CMD = $(ENVIRONMENT_VARS) .build/venv/bin/c2c-template --vars $(VARS_FILE)

.PHONY: help
help:
	@echo "Usage: make <target>"
	@echo
	@echo "Main targets:"
	@echo
	@echo "- build                Build and configure the project"
	@echo "- check                Perform a number of checks on the code"
	@echo "- serve                Run the development server (pserve)"
	@echo "- clean                Remove generated files"
	@echo "- cleanall             Remove all the build artefacts"
	@echo
	@echo "Secondary targets:"
	@echo
	@echo "- build-web            Build the javascript and the css"
	@echo "- build-server         Build the files required by the server"
	@echo "- compile-js-catalog   Compile the angular translation catalog"
	@echo "- update-translations  Update translation files from Transifex webservice"
	@echo "- flake8               Run flake8 checker on the Python code"
	@echo "- lint                 Check the JavaScript code with linters"
	@echo "- update-node-modules  Update node modules (using --force)"
	@echo

.PHONY: build
build: $(SITE_PACKAGES)/geoportailv3.egg-link build-web update-translations compile-js-catalog build-server

.PHONY: check
check: flake8 lint build-web

.PHONY: clean
clean:
	rm -f .build/node_modules.timestamp
	rm -f .build/dev-requirements.timestamp
	rm -f .build/venv.timestamp
	rm -f geoportailv3/locale/*.pot
	rm -rf geoportailv3/static/build
	rm -f $(TEMPLATE_FILES:.in=)
	rm -f $(MAKO_FILES:.mako=)
	rm -f $(JINJA_FILES:.jinja=)

.PHONY: cleanall
cleanall: clean
	rm -rf .build
	rm -rf node_modules

.PHONY: build-web
build-web: geoportailv3/static/build/build.js geoportailv3/static/build/build.css geoportailv3/static/build/build.min.css

.PHONY: compile-js-catalog
compile-js-catalog:  geoportailv3/static/build/locale/lb/geoportailv3.json geoportailv3/static/build/locale/en/geoportailv3.json geoportailv3/static/build/locale/de/geoportailv3.json geoportailv3/static/build/locale/fr/geoportailv3.json

.PHONY: flake8
flake8: .build/venv/bin/flake8
	.build/venv/bin/flake8 geoportailv3

.PHONY: build-server
build-server: $(TEMPLATE_FILES:.in=) $(MAKO_FILES:.mako=) $(JINJA_FILES:.jinja=) .build/config.yaml

.PHONY: lint
lint: .build/venv/bin/gjslint .build/node_modules.timestamp .build/gjslint.timestamp .build/jshint.timestamp

.PHONY: serve
serve: build development.ini
	.build/venv/bin/pserve --reload --monitor-restart development.ini

.PHONY: update-node-modules
update-node-modules:
	npm install --force

.PHONY: update-translations
update-translations: $(APP_PYTHON_FILES) $(APP_HTML_FILES) $(APP_SERVER_LOC_FILES) $(APP_CLIENT_LOC_FILES) $(APP_DB_LOC_FILES) geoportailv3/locale/geoportailv3-db.pot geoportailv3/locale/geoportailv3.pot geoportailv3/locale/geoportailv3-client.pot
	.build/venv/bin/tx push -s
	.build/venv/bin/tx pull -l en
	.build/venv/bin/tx pull -l fr
	.build/venv/bin/tx pull -l de
	.build/venv/bin/tx pull -l lb

$(TEMPLATE_FILES:.in=): $(TEMPLATE_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine template --files $@.in

$(MAKO_FILES:.mako=): $(MAKO_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine mako --files $@.mako

$(JINJA_FILES:.jinja=): $(JINJA_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine jinja --files $@.jinja

geoportailv3/closure/%.py: $(CLOSURE_LIBRARY_PATH)/closure/bin/build/%.py
	cp $< $@

geoportailv3/locale/geoportailv3-client.pot: $(APP_HTML_FILES)
	node tasks/extract-messages.js $^ > $@

geoportailv3/locale/geoportailv3.pot: $(APP_PYTHON_FILES) $(APP_HTML_FILES)
	.build/venv/bin/pot-create -c lingua.ini -o geoportailv3/locale/geoportailv3.pot geoportailv3

geoportailv3/locale/geoportailv3-db.pot:
	.build/venv/bin/python2.7 geoportailv3/utils/db_to_pot.py
	msguniq geoportailv3/locale/geoportailv3-db.pot -o geoportailv3/locale/geoportailv3-db.pot

$(APP_SERVER_LOC_FILES): geoportailv3/locale/geoportailv3.pot
	msgmerge --update $@ geoportailv3/locale/geoportailv3.pot
	msgfmt -o $(basename $@).mo $@

$(APP_CLIENT_LOC_FILES): geoportailv3/locale/geoportailv3-client.pot
	msgmerge --update $@ geoportailv3/locale/geoportailv3-client.pot
	msgfmt -o $(basename $@).mo $@

geoportailv3/static/build/locale/en/geoportailv3.json: geoportailv3/locale/en/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/en/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/fr/geoportailv3.json:  geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/de/geoportailv3.json: geoportailv3/locale/de/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/de/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/lb/geoportailv3.json: geoportailv3/locale/lb/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/lb/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/build.js: build.json $(OL_JS_FILES) $(NGEO_JS_FILES) $(APP_JS_FILES) .build/externs/angular-1.3.js .build/externs/angular-1.3-q.js .build/externs/angular-1.3-http-promise.js .build/node_modules.timestamp<commit_msg>bugfix to ensure that development.ini exists before db pot is created<commit_after>SITE_PACKAGES = $(shell .build/venv/bin/python -c "import distutils; print(distutils.sysconfig.get_python_lib())" 2> /dev/null)
PYTHON_VERSION = $(shell .build/venv/bin/python -c "import sys; print('%i.%i' % (sys.version_info.major, sys.version_info.minor))" 2> /dev/null)
OL_JS_FILES = $(shell find node_modules/openlayers/src/ol -type f -name '*.js' 2> /dev/null)
NGEO_JS_FILES = $(shell find node_modules/ngeo/src -type f -name '*.js' 2> /dev/null)
APP_JS_FILES = $(shell find geoportailv3/static/js -type f -name '*.js')
APP_HTML_FILES = $(shell find geoportailv3/templates -type f -name '*.html')
APP_PYTHON_FILES = $(shell find geoportailv3/ -type f -name '*.py')
APP_SERVER_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3.po')
APP_CLIENT_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3-client.po')
APP_DB_LOC_FILES = $(shell find geoportailv3/locale/ -type f -name 'geoportailv3-db.po')
LESS_FILES = $(shell find less -type f -name '*.less')
TEMPLATE_EXCLUDE += buildout .build CONST_alembic/script.py.mako print/templates/print.mako
FIND_OPTS = $(foreach ELEM, $(TEMPLATE_EXCLUDE),-path ./$(ELEM) -prune -o) -type f
TEMPLATE_FILES = $(shell find $(FIND_OPTS) -name "*.in" -print 2> /dev/null)
MAKO_FILES = $(shell find $(FIND_OPTS) -name "*.mako" -print 2> /dev/null)
JINJA_FILES = $(shell find $(FIND_OPTS) -name "*.jinja" -print 2> /dev/null)
VARS_FILES += CONST_vars.yaml
CONFIG_VARS += authtkt_cookie_name authtkt_secret sqlalchemy.url auth_replication_enabled \
	sqlalchemy_replication.url schema parentschema enable_admin_interface pyramid_closure.roots \
	pyramid_closure.roots_with_prefix node_modules_path closure_library_path default_locale_name \
	available_locale_names cache admin_interface functionalities external_themes_url \
	external_mapserv_url raster shortener mapserv_url hide_capabilities use_security_metadata \
	print_url tiles_url checker check_collector wfs default_max_age servers
ENVIRONMENT_VARS += INSTANCE_ID=${INSTANCE_ID}
C2C_TEMPLATE_CMD = $(ENVIRONMENT_VARS) .build/venv/bin/c2c-template --vars $(VARS_FILE)

.PHONY: help
help:
	@echo "Usage: make <target>"
	@echo
	@echo "Main targets:"
	@echo
	@echo "- build                Build and configure the project"
	@echo "- check                Perform a number of checks on the code"
	@echo "- serve                Run the development server (pserve)"
	@echo "- clean                Remove generated files"
	@echo "- cleanall             Remove all the build artefacts"
	@echo
	@echo "Secondary targets:"
	@echo
	@echo "- build-web            Build the javascript and the css"
	@echo "- build-server         Build the files required by the server"
	@echo "- compile-js-catalog   Compile the angular translation catalog"
	@echo "- update-translations  Update translation files from Transifex webservice"
	@echo "- flake8               Run flake8 checker on the Python code"
	@echo "- lint                 Check the JavaScript code with linters"
	@echo "- update-node-modules  Update node modules (using --force)"
	@echo

.PHONY: build
build: $(SITE_PACKAGES)/geoportailv3.egg-link build-web update-translations compile-js-catalog build-server

.PHONY: check
check: flake8 lint build-web

.PHONY: clean
clean:
	rm -f .build/node_modules.timestamp
	rm -f .build/dev-requirements.timestamp
	rm -f .build/venv.timestamp
	rm -f geoportailv3/locale/*.pot
	rm -rf geoportailv3/static/build
	rm -f $(TEMPLATE_FILES:.in=)
	rm -f $(MAKO_FILES:.mako=)
	rm -f $(JINJA_FILES:.jinja=)

.PHONY: cleanall
cleanall: clean
	rm -rf .build
	rm -rf node_modules

.PHONY: build-web
build-web: geoportailv3/static/build/build.js geoportailv3/static/build/build.css geoportailv3/static/build/build.min.css

.PHONY: compile-js-catalog
compile-js-catalog:  geoportailv3/static/build/locale/lb/geoportailv3.json geoportailv3/static/build/locale/en/geoportailv3.json geoportailv3/static/build/locale/de/geoportailv3.json geoportailv3/static/build/locale/fr/geoportailv3.json

.PHONY: flake8
flake8: .build/venv/bin/flake8
	.build/venv/bin/flake8 geoportailv3

.PHONY: build-server
build-server: $(TEMPLATE_FILES:.in=) $(MAKO_FILES:.mako=) $(JINJA_FILES:.jinja=) .build/config.yaml

.PHONY: lint
lint: .build/venv/bin/gjslint .build/node_modules.timestamp .build/gjslint.timestamp .build/jshint.timestamp

.PHONY: serve
serve: build development.ini
	.build/venv/bin/pserve --reload --monitor-restart development.ini

.PHONY: update-node-modules
update-node-modules:
	npm install --force

.PHONY: update-translations
update-translations: $(APP_PYTHON_FILES) $(APP_HTML_FILES) $(APP_SERVER_LOC_FILES) $(APP_CLIENT_LOC_FILES) $(APP_DB_LOC_FILES) geoportailv3/locale/geoportailv3-db.pot geoportailv3/locale/geoportailv3.pot geoportailv3/locale/geoportailv3-client.pot
	.build/venv/bin/tx push -s
	.build/venv/bin/tx pull -l en
	.build/venv/bin/tx pull -l fr
	.build/venv/bin/tx pull -l de
	.build/venv/bin/tx pull -l lb

$(TEMPLATE_FILES:.in=): $(TEMPLATE_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine template --files $@.in

$(MAKO_FILES:.mako=): $(MAKO_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine mako --files $@.mako

$(JINJA_FILES:.jinja=): $(JINJA_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	@echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	$(C2C_TEMPLATE_CMD) --engine jinja --files $@.jinja

geoportailv3/closure/%.py: $(CLOSURE_LIBRARY_PATH)/closure/bin/build/%.py
	cp $< $@

geoportailv3/locale/geoportailv3-client.pot: $(APP_HTML_FILES)
	node tasks/extract-messages.js $^ > $@

geoportailv3/locale/geoportailv3.pot: $(APP_PYTHON_FILES) $(APP_HTML_FILES)
	.build/venv/bin/pot-create -c lingua.ini -o geoportailv3/locale/geoportailv3.pot geoportailv3

geoportailv3/locale/geoportailv3-db.pot: development.ini
	.build/venv/bin/python2.7 geoportailv3/utils/db_to_pot.py
	msguniq geoportailv3/locale/geoportailv3-db.pot -o geoportailv3/locale/geoportailv3-db.pot

$(APP_SERVER_LOC_FILES): geoportailv3/locale/geoportailv3.pot
	msgmerge --update $@ geoportailv3/locale/geoportailv3.pot
	msgfmt -o $(basename $@).mo $@

$(APP_CLIENT_LOC_FILES): geoportailv3/locale/geoportailv3-client.pot
	msgmerge --update $@ geoportailv3/locale/geoportailv3-client.pot
	msgfmt -o $(basename $@).mo $@

geoportailv3/static/build/locale/en/geoportailv3.json: geoportailv3/locale/en/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/en/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/fr/geoportailv3.json:  geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/de/geoportailv3.json: geoportailv3/locale/de/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/de/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/locale/lb/geoportailv3.json: geoportailv3/locale/lb/LC_MESSAGES/geoportailv3-db.po geoportailv3/locale/lb/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $+ > $@

geoportailv3/static/build/build.js: build.json $(OL_JS_FILES) $(NGEO_JS_FILES) $(APP_JS_FILES) .build/externs/angular-1.3.js .build/externs/angular-1.3-q.js .build/externs/angular-1.3-http-promise.js .build/node_modules.timestamp
{'fraction_non_alphanumeric': 0.13175982362858255, 'fraction_numerical': 0.014395020101154196, 'mean_word_length': 4.531922525107604, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1593541', 'n_tokens_mistral': 6131, 'n_tokens_neox': 6004, 'n_words': 1146}