<commit_before>#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""
Plinth module to configure Tiny Tiny RSS.
"""

from django.utils.translation import ugettext_lazy as _
from plinth.utils import format_lazy

from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu

version = 1

managed_services = ['tt-rss']

managed_packages = ['tt-rss', 'postgresql', 'dbconfig-pgsql', 'php-pgsql']

name = _('Tiny Tiny RSS')

short_description = _('News Feed Reader')

description = [
    _('Tiny Tiny RSS is a news feed (RSS/Atom) reader and aggregator, '
      'designed to allow reading news from any location, while feeling as '
      'close to a real desktop application as possible.'),

    format_lazy(
        _('When enabled, Tiny Tiny RSS will be available from /tt-rss path on the web server. It can be accessed by '
          'any user with a {box_name} login.'),
        box_name=_(cfg.box_name))
]

service = None

def init():
    """Intialize the module."""
    menu = main_menu.get('apps')
    menu.add_urlname(name, 'glyphicon-envelope', 'ttrss:index', short_description)

    global service
    setup_helper = globals()['setup_helper']
    if setup_helper.get_state() != 'needs-setup':
        service = service_module.Service(
            managed_services[0], name, ports=['http', 'https'],
            is_external=True,
            is_enabled=is_enabled, enable=enable, disable=disable)

        if is_enabled():
            add_shortcut()

def setup(helper, old_version=None):
    """Install and configure the module."""
    helper.call('pre', actions.superuser_run, 'ttrss', ['pre-setup'])
    helper.install(managed_packages)
    helper.call('post', actions.superuser_run, 'ttrss', ['setup'])
    global service
    if service is None:
        service = service_module.Service(
            managed_services[0], name, ports=['http', 'https'],
            is_external=True,
            is_enabled=is_enabled, enable=enable, disable=disable)
    helper.call('post', service.notify_enabled, None, True)
    helper.call('post', add_shortcut)

def add_shortcut():
    frontpage.add_shortcut('ttrss', name, short_description=short_description, url='/tt-rss',
                           login_required=True)

def is_enabled():
    """Return whether the module is enabled."""
    return (action_utils.service_is_enabled('tt-rss') and
            action_utils.webserver_is_enabled('tt-rss-plinth'))

def enable():
    """Enable the module."""
    actions.superuser_run('ttrss', ['enable'])
    add_shortcut()

def disable():
    """Enable the module."""
    actions.superuser_run('ttrss', ['disable'])
    frontpage.remove_shortcut('ttrss')

def diagnose():
    """Run diagnostics and return the results."""
    results = []

    results.extend(action_utils.diagnose_url_on_all(
        'https://{host}/tt-rss', check_certificate=False))

    return results
<commit_msg>ttrss: Add description about availability of /tt-rss-app path<commit_after>#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""
Plinth module to configure Tiny Tiny RSS.
"""

from django.utils.translation import ugettext_lazy as _
from plinth.utils import format_lazy

from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu

version = 1

managed_services = ['tt-rss']

managed_packages = ['tt-rss', 'postgresql', 'dbconfig-pgsql', 'php-pgsql']

name = _('Tiny Tiny RSS')

short_description = _('News Feed Reader')

description = [
    _('Tiny Tiny RSS is a news feed (RSS/Atom) reader and aggregator, '
      'designed to allow reading news from any location, while feeling as '
      'close to a real desktop application as possible.'),

    format_lazy(
        _('When enabled, Tiny Tiny RSS will be available from /tt-rss path on the web server. It can be accessed by '
          'any user with a {box_name} login.'),
        box_name=_(cfg.box_name)),

    format_lazy(
        _('When using a mobile or desktop application for Tiny Tiny RSS, use '
          'the URL /tt-rss-app for connecting.'))
]

service = None

def init():
    """Intialize the module."""
    menu = main_menu.get('apps')
    menu.add_urlname(name, 'glyphicon-envelope', 'ttrss:index',
                     short_description)

    global service
    setup_helper = globals()['setup_helper']
    if setup_helper.get_state() != 'needs-setup':
        service = service_module.Service(
            managed_services[0], name, ports=['http', 'https'],
            is_external=True,
            is_enabled=is_enabled, enable=enable, disable=disable)

        if is_enabled():
            add_shortcut()

def setup(helper, old_version=None):
    """Install and configure the module."""
    helper.call('pre', actions.superuser_run, 'ttrss', ['pre-setup'])
    helper.install(managed_packages)
    helper.call('post', actions.superuser_run, 'ttrss', ['setup'])
    global service
    if service is None:
        service = service_module.Service(
            managed_services[0], name, ports=['http', 'https'],
            is_external=True,
            is_enabled=is_enabled, enable=enable, disable=disable)
    helper.call('post', service.notify_enabled, None, True)
    helper.call('post', add_shortcut)

def add_shortcut():
    """Add a shortcut to the front page."""
    frontpage.add_shortcut('ttrss', name, short_description=short_description,
                           url='/tt-rss', login_required=True)

def is_enabled():
    """Return whether the module is enabled."""
    return (action_utils.service_is_enabled('tt-rss') and
            action_utils.webserver_is_enabled('tt-rss-plinth'))

def enable():
    """Enable the module."""
    actions.superuser_run('ttrss', ['enable'])
    add_shortcut()

def disable():
    """Enable the module."""
    actions.superuser_run('ttrss', ['disable'])
    frontpage.remove_shortcut('ttrss')

def diagnose():
    """Run diagnostics and return the results."""
    results = []

    results.extend(action_utils.diagnose_url_on_all(
        'https://{host}/tt-rss', check_certificate=False))

    return results
<|endoftext|>


<commit_before>#!/usr/bin/env python2
# -*- coding: utf-8 -*-

#   Copyright (C) 2015  Neroburner
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

from __future__ import absolute_import
from __future__ import print_function
from __future__ import absolute_import

import os, sys
import logging

import config # user-credentials

from ext_libs.googleplay_api.googleplay import GooglePlayAPI #GooglePlayAPI
from ext_libs.googleplay_api.googleplay import LoginError
from ext_libs.androguard.core.bytecodes import apk as androguard_apk #Androguard

def connect():
	api = GooglePlayAPI(androidId=config.ANDROID_ID, lang=config.LANG)
	try :
		api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.AUTH_TOKEN)
	except LoginError, exc:
		logging.error("Connection to PlayStore failed: %s" % exc)
		return None

	logging.info("Connection to GooglePlayStore established")
	return api

def update(playstore_api, apk_folder_path):
	# search for apks in given folder
	list_of_apks = [filename for filename in os.listdir(apk_folder_path) if os.path.splitext(filename)[1] == ".apk"]
	if len(list_of_apks) <= 0:
		print("No apks found in folder %s" % apk_folder_path)
		sys.exit(0)

	# create a list of apks, just keep the newest
	apks_to_update = dict()
	for filename in list_of_apks:
		filepath = os.path.join(apk_folder_path, filename)
		a = androguard_apk.APK(filepath)
		apk_version_code = int(a.get_androidversion_code())
		packagename = a.get_package()

		logging.info("Found apk %s : %s : %d" % (filepath, packagename, apk_version_code))

		if packagename in apks_to_update:
			if apks_to_update[packagename] < apk_version_code:
				logging.info("Found newer local version %s : %d -> %d" % (packagename, apks_to_update[packagename], apk_version_code))
				apks_to_update[packagename] = apk_version_code

		else:
			logging.info("Set new  local apk %s : %d" % (packagename, apk_version_code))
			apks_to_update[packagename] = apk_version_code

	# are there still apks to check? If not something went wrong
	if len(apks_to_update) <= 0:
		logging.error("No apks to update after non-empty apk-list. Something went wrong!")
		sys.exit(1)

	# search for the apks on googleplaystore
	for packagename, version_code in apks_to_update.items():
		local_version_code = int(version_code)
		logging.info("Checking apk %s : %d" % (packagename, local_version_code))

		# get infos of the store-version
		m = playstore_api.details(packagename)
		doc = m.docV2
		store_version_code = int(doc.details.appDetails.versionCode)

		if store_version_code == 0:
			logging.warning("Got store_version_code == 0 for package %s : %d" % (packagename, local_version_code))
			continue

		# check if there is an update
		if store_version_code > local_version_code:
			# download apk from store
			print("Updating apk %s : %d -> %d" % (packagename, local_version_code, store_version_code))
			try:
				data = playstore_api.download(packagename, store_version_code)
			except Exception as exc:
				logging.error("failed to download %s : %s" % (packagename, exc))
				continue
			else:
				# save downloaded apk under '<packagename>_<version>.apk'
				filename = "%s_%d.apk" % (packagename, store_version_code)
				filepath = os.path.join(apk_folder_path, filename)

				try:
					open(filepath, "wb").write(data)
				except IOError, exc:
					logging.error("cannot write to disk %s : %s" % (packagename, exc))
					continue
				logging.info("Downloaded apk %s : %d to file %s" % (packagename, store_version_code, filename))
		else:
			logging.info("No newer apk found.")

def synopsis():
	print("Usage: %s [-v] <apk_folder_path>" % sys.argv[0])
	print("\t-v\t verbose output")

def main():
	#print(sys.argv)
	min_argc = 2
	path_index = 1

	# Check arguments
	if "-v" in sys.argv:
		min_argc += 1
		path_index += 1
		logging.basicConfig(level=logging.INFO)

	# TODO: --config flag

	if len(sys.argv) < min_argc:
		synopsis()
		sys.exit(1)

	# get apk_folder_path
	apk_folder_path = sys.argv[path_index]
	if not os.path.isdir(apk_folder_path):
		logging.error("given <apk_folder_path> is not a directory: %s" % apk_folder_path)
		synopsis()
		sys.exit(1)

	# connect to Google Play Store
	playstore_api = connect()
	if playstore_api == None:
		logging.error("Connection to PlayStore failed. Check provided credencials in config.py")
		sys.exit(1)

	# update local apks
	update(playstore_api, apk_folder_path)

if __name__ == '__main__':
	main()

<commit_msg>formatting<commit_after>#!/usr/bin/env python2
# -*- coding: utf-8 -*-

#   Copyright (C) 2015  Neroburner
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

from __future__ import absolute_import
from __future__ import print_function
from __future__ import absolute_import

import os, sys
import logging

import config # user-credentials

from ext_libs.googleplay_api.googleplay import GooglePlayAPI #GooglePlayAPI
from ext_libs.googleplay_api.googleplay import LoginError
from ext_libs.androguard.core.bytecodes import apk as androguard_apk #Androguard

def connect():
    api = GooglePlayAPI(androidId=config.ANDROID_ID, lang=config.LANG)
    try :
        api.login(config.GOOGLE_LOGIN, config.GOOGLE_PASSWORD, config.AUTH_TOKEN)
    except LoginError, exc:
        logging.error("Connection to PlayStore failed: %s" % exc)
        return None

    logging.info("Connection to GooglePlayStore established")
    return api

def update(playstore_api, apk_folder_path):
    # search for apks in given folder
    list_of_apks = [filename for filename in os.listdir(apk_folder_path) if os.path.splitext(filename)[1] == ".apk"]
    if len(list_of_apks) <= 0:
        print("No apks found in folder %s" % apk_folder_path)
        sys.exit(0)

    # create a list of apks, just keep the newest
    apks_to_update = dict()
    for filename in list_of_apks:
        filepath = os.path.join(apk_folder_path, filename)
        a = androguard_apk.APK(filepath)
        apk_version_code = int(a.get_androidversion_code())
        packagename = a.get_package()

        logging.info("Found apk %s : %s : %d" % (filepath, packagename, apk_version_code))

        if packagename in apks_to_update:
            if apks_to_update[packagename] < apk_version_code:
                logging.info("Found newer local version %s : %d -> %d" % (packagename, apks_to_update[packagename], apk_version_code))
                apks_to_update[packagename] = apk_version_code

        else:
            logging.info("Set new  local apk %s : %d" % (packagename, apk_version_code))
            apks_to_update[packagename] = apk_version_code

    # are there still apks to check? If not something went wrong
    if len(apks_to_update) <= 0:
        logging.error("No apks to update after non-empty apk-list. Something went wrong!")
        sys.exit(1)

    # search for the apks on googleplaystore
    for packagename, version_code in apks_to_update.items():
        local_version_code = int(version_code)
        logging.info("Checking apk %s : %d" % (packagename, local_version_code))

        # get infos of the store-version
        m = playstore_api.details(packagename)
        doc = m.docV2
        store_version_code = int(doc.details.appDetails.versionCode)

        if store_version_code == 0:
            logging.warning("Got store_version_code == 0 for package %s : %d" % (packagename, local_version_code))
            continue

        # check if there is an update
        if store_version_code > local_version_code:
            # download apk from store
            print("Updating apk %s : %d -> %d" % (packagename, local_version_code, store_version_code))
            try:
                data = playstore_api.download(packagename, store_version_code)
            except Exception as exc:
                logging.error("failed to download %s : %s" % (packagename, exc))
                continue
            else:
                # save downloaded apk under '<packagename>_<version>.apk'
                filename = "%s_%d.apk" % (packagename, store_version_code)
                filepath = os.path.join(apk_folder_path, filename)

                try:
                    open(filepath, "wb").write(data)
                except IOError, exc:
                    logging.error("cannot write to disk %s : %s" % (packagename, exc))
                    continue
                logging.info("Downloaded apk %s : %d to file %s" % (packagename, store_version_code, filename))
        else:
            logging.info("No newer apk found.")

def synopsis():
    print("Usage: %s [-v] <apk_folder_path>" % sys.argv[0])
    print("\t-v\t verbose output")

def main():
    #print(sys.argv)
    min_argc = 2
    path_index = 1

    # Check arguments
    if "-v" in sys.argv:
        min_argc += 1
        path_index += 1
        logging.basicConfig(level=logging.INFO)

    # TODO: --config flag

    if len(sys.argv) < min_argc:
        synopsis()
        sys.exit(1)

    # get apk_folder_path
    apk_folder_path = sys.argv[path_index]
    if not os.path.isdir(apk_folder_path):
        logging.error("given <apk_folder_path> is not a directory: %s" % apk_folder_path)
        synopsis()
        sys.exit(1)

    # connect to Google Play Store
    playstore_api = connect()
    if playstore_api == None:
        logging.error("Connection to PlayStore failed. Check provided credencials in config.py")
        sys.exit(1)

    # update local apks
    update(playstore_api, apk_folder_path)

if __name__ == '__main__':
    main()

<|endoftext|>


<commit_before>from __future__ import print_function
from brian import *
import spikerlib as sl
import itertools as itt

# unit aliases
ms = msecond
Hz = hertz
mV = mvolt

# measure aliases
victor_purpura = sl.metrics.victor_purpura
kreuz = sl.metrics.kreuz
modulus = sl.metrics.modulus_metric
npss = sl.tools.normalised_pre_spike_slopes

netw = Network()
lif_neuron = NeuronGroup(1, "dV/dt = -V/(10*ms) : volt",
                         threshold="V>15*mV", reset="V=0*mV")
lif_neuron.V = 0*mV
netw.add(lif_neuron)

Nin = 20
input_idx = range(Nin)
# three spikes caused by high early synchrony with low late synchrony
input_times = []
for strt in [0, 50, 100, 150, 200]:
    new_its = [17*ms]*5+[18*ms]*5+[st*ms for st in range(20, 30)]
    input_times += [ni+strt*ms for ni in new_its]
# three more caused by the opposite
for strt in [250, 300, 350, 400, 450]:
    new_its = [st*ms for st in range(10, 20)]+[25*ms]*5+[26*ms]*5
    input_times += [ni+strt*ms for ni in new_its]

# convert to (input, time) pairs
input_spikes = [(i, t) for i, t in zip(itt.cycle(input_idx), input_times)]
#print(input_spikes)
input_group = SpikeGeneratorGroup(Nin, input_spikes)
connection = Connection(input_group, lif_neuron, "V", weight=1.6*mV)
netw.add(input_group, connection)

input_mon = SpikeMonitor(input_group)
output_mon = SpikeMonitor(lif_neuron)
trace_mon = StateMonitor(lif_neuron, "V", record=True)
netw.add(input_mon, output_mon, trace_mon)

netw.run(500*ms)

spiketimes = [0]+list(output_mon[0])
npss_slope = []
kreuz_dist = [[],[]]
kreuz_means = []
victor = []
for prev_st, spiketime in zip(spiketimes[:-1], spiketimes[1:]):
    print("%f --> %f" % (prev_st, spiketime))
    npss_slope.append(npss(trace_mon[0], array([prev_st, spiketime]),
                      0*mV, 15*mV, 10*ms, 2*ms)[0])

    input_spikes = input_mon.spiketimes.values()

    isi = spiketime-prev_st
    kreuz_bins = int(isi/ms)
    t, krd = kreuz.interval(input_spikes, [prev_st, spiketime], kreuz_bins)
    kreuz_dist[0].extend(list(t[0]))
    kreuz_dist[1].extend(list(krd[0]))
    kreuz_means.append(mean(krd))

    victor.append(victor_purpura.interval(input_spikes,
                                          [prev_st, spiketime],
                                          float(1/(2*ms)))[0])

interval_midpoints = add(spiketimes[1:], spiketimes[:-1])/2
xmax=trace_mon.times[-1]
trace_mon.insert_spikes(output_mon, 20*mV)
subplot(3,1,1)
raster_plot(input_mon)
for st in spiketimes:
    plot([st/ms, st/ms], [-1, max(input_idx)+1], "k-")
axis(xmin=0, xmax=xmax/float(ms))
subplot(3,1,2)
plot(trace_mon.times, trace_mon[0], "k")
subplot(3,1,3)
plot(interval_midpoints, npss_slope, "b-", label="NPSS")
plot(kreuz_dist[0], kreuz_dist[1], "r--", label="Kreuz")
plot(interval_midpoints, kreuz_means, "r-", label="Kreuz mean")
plot(interval_midpoints, victor, "g-", label="V-P")
metric_axes = axis()
for st in spiketimes:
    plot([st, st], [0, 10], "k-")
axis(metric_axes)
axis(xmin=0, xmax=xmax)
legend()
show()

<commit_msg>Still not working as intended<commit_after>from __future__ import print_function
from brian import *
import spikerlib as sl
import itertools as itt

# unit aliases
ms = msecond
Hz = hertz
mV = mvolt

# measure aliases
victor_purpura = sl.metrics.victor_purpura
kreuz = sl.metrics.kreuz
modulus = sl.metrics.modulus_metric
npss = sl.tools.normalised_pre_spike_slopes

netw = Network()
lif_neuron = NeuronGroup(1, "dV/dt = -V/(10*ms) : volt",
                         threshold="V>15*mV", reset="V=0*mV")
lif_neuron.V = 0*mV
netw.add(lif_neuron)

Nin = 20
input_idx = range(Nin)
input_times = []
# three more caused by the opposite
for strt in [50, 100, 150, 200]:
    new_its = ([ni*ms for ni in np.random.normal(10, 1.0, 10)]+
               [ni*ms for ni in np.random.normal(20, 1.5, 10)])
    input_times += [ni+strt*ms for ni in new_its]
# three spikes caused by high early synchrony with low late synchrony
for strt in [250, 300, 350, 400, 450]:
    new_its = ([ni*ms for ni in np.random.normal(20, 0.5, 10)]+
               [ni*ms for ni in np.random.normal(10, 2.0, 10)])
    input_times += [ni+strt*ms for ni in new_its]
# convert to (input, time) pairs
input_spikes = [(i, t) for i, t in zip(itt.cycle(input_idx), input_times)]
#print(input_spikes)
input_group = SpikeGeneratorGroup(Nin, input_spikes)
connection = Connection(input_group, lif_neuron, "V", weight=1.6*mV)
netw.add(input_group, connection)

input_mon = SpikeMonitor(input_group)
output_mon = SpikeMonitor(lif_neuron)
trace_mon = StateMonitor(lif_neuron, "V", record=True)
netw.add(input_mon, output_mon, trace_mon)

netw.run(500*ms)

spiketimes = [0]+list(output_mon[0])
npss_slope = []
kreuz_dist = [[],[]]
kreuz_means = []
victor = []
for prev_st, spiketime in zip(spiketimes[:-1], spiketimes[1:]):
    print("%f --> %f" % (prev_st, spiketime))
    npss_slope.append(npss(trace_mon[0], array([prev_st, spiketime]),
                      0*mV, 15*mV, 10*ms, 2*ms)[0])

    input_spikes = input_mon.spiketimes.values()

    isi = spiketime-prev_st
    kreuz_bins = int(isi/(2*ms))
    t, krd = kreuz.interval(input_spikes, [prev_st, spiketime], kreuz_bins)
    kreuz_dist[0].extend(list(t[0]))
    kreuz_dist[1].extend(list(krd[0]))
    kreuz_means.append(mean(krd))

    victor.append(victor_purpura.interval(input_spikes,
                                          [prev_st, spiketime],
                                          float(1/(2*ms)))[0])

interval_midpoints = add(spiketimes[1:], spiketimes[:-1])/2
xmax=trace_mon.times[-1]
trace_mon.insert_spikes(output_mon, 20*mV)
subplot(3,1,1)
raster_plot(input_mon)
for st in spiketimes:
    plot([st/ms, st/ms], [-1, max(input_idx)+1], "k-")
axis(xmin=0, xmax=xmax/float(ms))
subplot(3,1,2)
plot(trace_mon.times, trace_mon[0], "k")
subplot(3,1,3)
plot(interval_midpoints, npss_slope, "b-", label="NPSS")
plot(kreuz_dist[0], kreuz_dist[1], "r--", label="Kreuz")
plot(interval_midpoints, kreuz_means, "r-", label="Kreuz mean")
plot(interval_midpoints, victor, "g-", label="V-P")
metric_axes = axis()
for st in spiketimes:
    plot([st, st], [0, 10], "k-")
axis(metric_axes)
axis(xmin=0, xmax=xmax)
legend()
show()

<|endoftext|>


<commit_before>import sys

import yaml
import jinja2

TECHNOLOGY_COLUMNS = 3
SKILLS_COLUMNS = 2

def render_html(resume_file):
    with open(resume_file) as f:
        resume = yaml.load(f)

    env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
    template = env.get_template('resume.html')

    resume["technology"]["columns"] = TECHNOLOGY_COLUMNS
    resume["skills"]["columns"] = SKILLS_COLUMNS

    return template.render(resume)

if __name__ == "__main__":

    resume_file = sys.argv[1]
    print render_html(resume_file)<commit_msg>more flexible html generation<commit_after>import sys
import tempfile
import shutil, os.path

import yaml
import jinja2

TECHNOLOGY_COLUMNS = 3
SKILLS_COLUMNS = 2

def render_html(yaml_file):
    with open(yaml_file) as f:
        resume = yaml.load(f)

    env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
    template = env.get_template('resume.html')

    resume["technology"]["columns"] = TECHNOLOGY_COLUMNS
    resume["skills"]["columns"] = SKILLS_COLUMNS

    return template.render(resume)

def create_html_file(yaml_file):
    html = render_html(yaml_file)
    temp_name = tempfile.NamedTemporaryFile().name
    filename = temp_name + ".html"
    with open(filename, 'w') as f:
        f.write(html)

    return filename

if __name__ == "__main__":

    resume_file = sys.argv[1]

    try:
        html_file = create_html_file(resume_file)
        destination = os.path.splitext(os.path.basename(resume_file))[0] + ".html"
        shutil.move(html_file, destination)
        print "Created {0} from {1}".format(destination, resume_file)
    except:
        print "Error creating html file"<|endoftext|>


<commit_before>{
  'variables': {
    # The libraries brightray will be compiled to.
    'linux_system_libraries': 'gtk+-2.0 dbus-1 x11 xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss'
  },
  'includes': [
    'filenames.gypi',
  ],
  'targets': [
    {
      'target_name': 'brightray',
      'type': 'static_library',
      'include_dirs': [
        '.',
        '<(libchromiumcontent_src_dir)',
        '<(libchromiumcontent_src_dir)/skia/config',
        '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
        '<(libchromiumcontent_src_dir)/third_party/mojo/src',
        '<(libchromiumcontent_src_dir)/third_party/WebKit',
        '<(libchromiumcontent_dir)/gen',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '.',
          '..',
          '<(libchromiumcontent_src_dir)',
          '<(libchromiumcontent_src_dir)/skia/config',
          '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
          '<(libchromiumcontent_src_dir)/third_party/icu/source/common',
          '<(libchromiumcontent_src_dir)/third_party/mojo/src',
          '<(libchromiumcontent_src_dir)/third_party/WebKit',
          '<(libchromiumcontent_dir)/gen',
        ],
      },
      'sources': [ '<@(brightray_sources)' ],
      'conditions': [
        # Link with libraries of libchromiumcontent.
        ['OS=="linux" and libchromiumcontent_component==0', {
          # On Linux we have to use "--start-group" or we will have plenty of
          # unresolved symbols errors.
          'link_settings': {
            'libraries': [
              '-Wl,--start-group',
              '<@(libchromiumcontent_libraries)',
              '-Wl,--end-group'
            ],
          }
        }, {  # (Release build on Linux)
          'link_settings': {
            'libraries': [ '<@(libchromiumcontent_libraries)' ]
          },
        }],  # (Normal builds)
        # Linux specific link settings.
        ['OS=="linux"', {
          'link_settings': {
            'ldflags': [
              '<!@(<(pkg-config) --libs-only-L --libs-only-other <(linux_system_libraries))',
            ],
            'libraries': [
              '-lpthread',
              '<!@(<(pkg-config) --libs-only-l <(linux_system_libraries))',
            ],
          },
          'cflags': [
            '<!@(<(pkg-config) --cflags <(linux_system_libraries))',
            # Needed by using libgtk2ui:
            '-Wno-deprecated-register',
            '-Wno-sentinel',
          ],
          'cflags_cc': [
            '-Wno-reserved-user-defined-literal',
          ],
          'direct_dependent_settings': {
            'cflags': [
              '<!@(<(pkg-config) --cflags <(linux_system_libraries))',
              '-Wno-deprecated-register',
              '-Wno-sentinel',
            ],
          },
          'conditions': [
            ['libchromiumcontent_component', {
              'link_settings': {
                'libraries': [
                  # Following libraries are always linked statically.
                  '<(libchromiumcontent_dir)/libgtk2ui.a',
                  '<(libchromiumcontent_dir)/libdevtools_discovery.a',
                  '<(libchromiumcontent_dir)/libdevtools_http_handler.a',
                  '<(libchromiumcontent_dir)/libhttp_server.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                  '<(libchromiumcontent_dir)/libsystem_wrappers.a',
                  '<(libchromiumcontent_dir)/librtc_base.a',
                  '<(libchromiumcontent_dir)/librtc_base_approved.a',
                  '<(libchromiumcontent_dir)/libwebrtc_common.a',
                  '<(libchromiumcontent_dir)/libyuv.a',
                  '<(libchromiumcontent_dir)/libcdm_renderer.a',
                  '<(libchromiumcontent_dir)/libsecurity_state.a',
                ],
              },
            }, {
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/libffmpeg.so',
                  # Following libraries are required by libchromiumcontent:
                  '-lasound',
                  '-lcap',
                  '-lcups',
                  '-lrt',
                  '-ldl',
                  '-lresolv',
                  '-lfontconfig',
                  '-lfreetype',
                  '-lexpat',
                ],
              },
            }],
            ['target_arch=="arm"', {
              'link_settings': {
                'libraries!': [
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                ],
              },
            }],
          ],
        }],  # OS=="linux"
        ['OS=="mac"', {
          'link_settings': {
            'libraries': [
              '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
              # Required by webrtc:
              '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
              '$(SDKROOT)/System/Library/Frameworks/IOKit.framework',
            ],
          },
          'conditions':  [
            ['libchromiumcontent_component', {
              'link_settings': {
                'libraries': [
                  # Following libraries are always linked statically.
                  '<(libchromiumcontent_dir)/libdevtools_discovery.a',
                  '<(libchromiumcontent_dir)/libdevtools_http_handler.a',
                  '<(libchromiumcontent_dir)/libhttp_server.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                  '<(libchromiumcontent_dir)/librtc_base.a',
                  '<(libchromiumcontent_dir)/librtc_base_approved.a',
                  '<(libchromiumcontent_dir)/libsystem_wrappers.a',
                  '<(libchromiumcontent_dir)/libwebrtc_common.a',
                  '<(libchromiumcontent_dir)/libyuv.a',
                  '<(libchromiumcontent_dir)/libcdm_renderer.a',
                  '<(libchromiumcontent_dir)/libsecurity_state.a',
                ],
              },
            }, {
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/libffmpeg.dylib',
                  # Link with system frameworks.
                  # ui_base.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
                  # net.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
                  '$(SDKROOT)/System/Library/Frameworks/Security.framework',
                  '$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework',
                  '-lresolv',
                  # media.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/AudioToolbox.framework',
                  '$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework',
                  '$(SDKROOT)/System/Library/Frameworks/AVFoundation.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreAudio.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreMedia.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreMIDI.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework',
                  # surface.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/IOSurface.framework',
                  # content_common.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
                  # base.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
                  '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
                  # content_browser.gypi:
                  '-lbsm',
                  # content_common.gypi:
                  '-lsandbox',
                  # bluetooth.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/IOBluetooth.framework',
                ],
              },
            }],
          ]
        }],  # OS=="mac"
        ['OS=="win"', {
          'conditions': [
            ['libchromiumcontent_component', {
              # sandbox, base_static, devtools_discovery, devtools_http_handler,
              # http_server are always linked statically.
              'link_settings': {
                'libraries': [
                  '<(libchromiumcontent_dir)/base_static.lib',
                  '<(libchromiumcontent_dir)/sandbox.lib',
                  '<(libchromiumcontent_dir)/sandbox_helper_win.lib',
                  '<(libchromiumcontent_dir)/devtools_discovery.lib',
                  '<(libchromiumcontent_dir)/devtools_http_handler.lib',
                  '<(libchromiumcontent_dir)/http_server.lib',
                  '<(libchromiumcontent_dir)/desktop_capture.lib',
                  '<(libchromiumcontent_dir)/desktop_capture_differ_sse2.lib',
                  '<(libchromiumcontent_dir)/rtc_base.lib',
                  '<(libchromiumcontent_dir)/rtc_base_approved.lib',
                  '<(libchromiumcontent_dir)/system_wrappers.lib',
                  '<(libchromiumcontent_dir)/webrtc_common.lib',
                  '<(libchromiumcontent_dir)/libyuv.lib',
                  '<(libchromiumcontent_dir)/cdm_renderer.lib',
                  '<(libchromiumcontent_dir)/security_state.lib',
                  # Friends of pdf.lib:
                  '<(libchromiumcontent_dir)/pdf.lib',
                  '<(libchromiumcontent_dir)/ppapi_cpp_objects.lib',
                  '<(libchromiumcontent_dir)/ppapi_internal_module.lib',
                  '<(libchromiumcontent_dir)/libjpeg.lib',
                  '<(libchromiumcontent_dir)/pdfium.lib',
                  '<(libchromiumcontent_dir)/fdrm.lib',
                  '<(libchromiumcontent_dir)/formfiller.lib',
                  '<(libchromiumcontent_dir)/fpdfapi.lib',
                  '<(libchromiumcontent_dir)/fpdfdoc.lib',
                  '<(libchromiumcontent_dir)/fpdftext.lib',
                  '<(libchromiumcontent_dir)/fpdftext.lib',
                  '<(libchromiumcontent_dir)/fxcodec.lib',
                  '<(libchromiumcontent_dir)/fxcrt.lib',
                  '<(libchromiumcontent_dir)/fxedit.lib',
                  '<(libchromiumcontent_dir)/fxge.lib',
                  '<(libchromiumcontent_dir)/javascript.lib',
                  '<(libchromiumcontent_dir)/pdfwindow.lib',
                  '<(libchromiumcontent_dir)/bigint.lib',
                  '<(libchromiumcontent_dir)/fx_agg.lib',
                  '<(libchromiumcontent_dir)/fx_freetype.lib',
                  '<(libchromiumcontent_dir)/fx_lcms2.lib',
                  '<(libchromiumcontent_dir)/fx_libopenjpeg.lib',
                  '<(libchromiumcontent_dir)/fx_zlib.lib',
                ],
              },
            }, {
              # Link with system libraries.
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/ffmpeg.dll',
                  # content_browser.gypi:
                  '-lsensorsapi.lib',
                  '-lportabledeviceguids.lib',
                  # content_common.gypi:
                  '-ld3d9.lib',
                  '-ld3d11.lib',
                  '-ldxva2.lib',
                  '-lstrmiids.lib',
                  '-lmf.lib',
                  '-lmfplat.lib',
                  '-lmfuuid.lib',
                  # media.gyp:
                  '-ldxguid.lib',
                  '-lmfreadwrite.lib',
                  '-lmfuuid.lib',
                ],
                'msvs_settings': {
                  'VCLinkerTool': {
                    'AdditionalDependencies': [
                      'advapi32.lib',
                      'dbghelp.lib',
                      'delayimp.lib',
                      'dwmapi.lib',
                      'gdi32.lib',
                      'netapi32.lib',
                      'oleacc.lib',
                      'user32.lib',
                      'usp10.lib',
                      'version.lib',
                      'winspool.lib',
                      'wtsapi32.lib',
                      # bluetooth.gyp:
                      'Bthprops.lib',
                      'BluetoothApis.lib',
                      # base.gyp:
                      'cfgmgr32.lib',
                      'powrprof.lib',
                      'setupapi.lib',
                      # net_common.gypi:
                      'crypt32.lib',
                      'dhcpcsvc.lib',
                      'rpcrt4.lib',
                      'secur32.lib',
                      'urlmon.lib',
                      'winhttp.lib',
                    ],
                    'DelayLoadDLLs': [
                      'wtsapi32.dll',
                      # content_common.gypi:
                      'd3d9.dll',
                      'd3d11.dll',
                      'dxva2.dll',
                      # media.gyp:
                      'mf.dll',
                      'mfplat.dll',
                      'mfreadwrite.dll',
                      # bluetooth.gyp:
                      'BluetoothApis.dll',
                      'Bthprops.cpl',
                      'setupapi.dll',
                      # base.gyp:
                      'cfgmgr32.dll',
                      'powrprof.dll',
                      'setupapi.dll',
                      # net_common.gypi:
                      'crypt32.dll',
                      'dhcpcsvc.dll',
                      'rpcrt4.dll',
                      'secur32.dll',
                      'urlmon.dll',
                      'winhttp.dll',
                      # windows runtime
                      'API-MS-WIN-CORE-WINRT-L1-1-0.DLL',
                      'API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL',
                    ],
                  },
                },
              },
            }],  # libchromiumcontent_component
          ],
        }],  # OS=="win"
      ],
    },
  ],
}
<commit_msg>Revert "Replace --whole-archive with --start-group"<commit_after>{
  'variables': {
    # The libraries brightray will be compiled to.
    'linux_system_libraries': 'gtk+-2.0 dbus-1 x11 xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss'
  },
  'includes': [
    'filenames.gypi',
  ],
  'targets': [
    {
      'target_name': 'brightray',
      'type': 'static_library',
      'include_dirs': [
        '.',
        '<(libchromiumcontent_src_dir)',
        '<(libchromiumcontent_src_dir)/skia/config',
        '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
        '<(libchromiumcontent_src_dir)/third_party/mojo/src',
        '<(libchromiumcontent_src_dir)/third_party/WebKit',
        '<(libchromiumcontent_dir)/gen',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '.',
          '..',
          '<(libchromiumcontent_src_dir)',
          '<(libchromiumcontent_src_dir)/skia/config',
          '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
          '<(libchromiumcontent_src_dir)/third_party/icu/source/common',
          '<(libchromiumcontent_src_dir)/third_party/mojo/src',
          '<(libchromiumcontent_src_dir)/third_party/WebKit',
          '<(libchromiumcontent_dir)/gen',
        ],
      },
      'sources': [ '<@(brightray_sources)' ],
      'conditions': [
        # Link with libraries of libchromiumcontent.
        ['OS=="linux" and libchromiumcontent_component==0', {
          # On Linux we have to use "--whole-archive" to force executable
          # to include all symbols, otherwise we will have plenty of
          # unresolved symbols errors.
          'direct_dependent_settings': {
            'ldflags': [
              '-Wl,--whole-archive',
              '<@(libchromiumcontent_libraries)',
              '-Wl,--no-whole-archive',
            ],
          }
        }, {  # (Release build on Linux)
          'link_settings': {
            'libraries': [ '<@(libchromiumcontent_libraries)' ]
          },
        }],  # (Normal builds)
        # Linux specific link settings.
        ['OS=="linux"', {
          'link_settings': {
            'ldflags': [
              '<!@(<(pkg-config) --libs-only-L --libs-only-other <(linux_system_libraries))',
            ],
            'libraries': [
              '-lpthread',
              '<!@(<(pkg-config) --libs-only-l <(linux_system_libraries))',
            ],
          },
          'cflags': [
            '<!@(<(pkg-config) --cflags <(linux_system_libraries))',
            # Needed by using libgtk2ui:
            '-Wno-deprecated-register',
            '-Wno-sentinel',
          ],
          'cflags_cc': [
            '-Wno-reserved-user-defined-literal',
          ],
          'direct_dependent_settings': {
            'cflags': [
              '<!@(<(pkg-config) --cflags <(linux_system_libraries))',
              '-Wno-deprecated-register',
              '-Wno-sentinel',
            ],
          },
          'conditions': [
            ['libchromiumcontent_component', {
              'link_settings': {
                'libraries': [
                  # Following libraries are always linked statically.
                  '<(libchromiumcontent_dir)/libgtk2ui.a',
                  '<(libchromiumcontent_dir)/libdevtools_discovery.a',
                  '<(libchromiumcontent_dir)/libdevtools_http_handler.a',
                  '<(libchromiumcontent_dir)/libhttp_server.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                  '<(libchromiumcontent_dir)/libsystem_wrappers.a',
                  '<(libchromiumcontent_dir)/librtc_base.a',
                  '<(libchromiumcontent_dir)/librtc_base_approved.a',
                  '<(libchromiumcontent_dir)/libwebrtc_common.a',
                  '<(libchromiumcontent_dir)/libyuv.a',
                  '<(libchromiumcontent_dir)/libcdm_renderer.a',
                  '<(libchromiumcontent_dir)/libsecurity_state.a',
                ],
              },
            }, {
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/libffmpeg.so',
                  # Following libraries are required by libchromiumcontent:
                  '-lasound',
                  '-lcap',
                  '-lcups',
                  '-lrt',
                  '-ldl',
                  '-lresolv',
                  '-lfontconfig',
                  '-lfreetype',
                  '-lexpat',
                ],
              },
            }],
            ['target_arch=="arm"', {
              'link_settings': {
                'libraries!': [
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                ],
              },
            }],
          ],
        }],  # OS=="linux"
        ['OS=="mac"', {
          'link_settings': {
            'libraries': [
              '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
              # Required by webrtc:
              '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
              '$(SDKROOT)/System/Library/Frameworks/IOKit.framework',
            ],
          },
          'conditions':  [
            ['libchromiumcontent_component', {
              'link_settings': {
                'libraries': [
                  # Following libraries are always linked statically.
                  '<(libchromiumcontent_dir)/libdevtools_discovery.a',
                  '<(libchromiumcontent_dir)/libdevtools_http_handler.a',
                  '<(libchromiumcontent_dir)/libhttp_server.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture.a',
                  '<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
                  '<(libchromiumcontent_dir)/librtc_base.a',
                  '<(libchromiumcontent_dir)/librtc_base_approved.a',
                  '<(libchromiumcontent_dir)/libsystem_wrappers.a',
                  '<(libchromiumcontent_dir)/libwebrtc_common.a',
                  '<(libchromiumcontent_dir)/libyuv.a',
                  '<(libchromiumcontent_dir)/libcdm_renderer.a',
                  '<(libchromiumcontent_dir)/libsecurity_state.a',
                ],
              },
            }, {
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/libffmpeg.dylib',
                  # Link with system frameworks.
                  # ui_base.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
                  # net.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
                  '$(SDKROOT)/System/Library/Frameworks/Security.framework',
                  '$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework',
                  '-lresolv',
                  # media.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/AudioToolbox.framework',
                  '$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework',
                  '$(SDKROOT)/System/Library/Frameworks/AVFoundation.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreAudio.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreMedia.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreMIDI.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework',
                  # surface.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/IOSurface.framework',
                  # content_common.gypi:
                  '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
                  # base.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
                  '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
                  '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
                  # content_browser.gypi:
                  '-lbsm',
                  # content_common.gypi:
                  '-lsandbox',
                  # bluetooth.gyp:
                  '$(SDKROOT)/System/Library/Frameworks/IOBluetooth.framework',
                ],
              },
            }],
          ]
        }],  # OS=="mac"
        ['OS=="win"', {
          'conditions': [
            ['libchromiumcontent_component', {
              # sandbox, base_static, devtools_discovery, devtools_http_handler,
              # http_server are always linked statically.
              'link_settings': {
                'libraries': [
                  '<(libchromiumcontent_dir)/base_static.lib',
                  '<(libchromiumcontent_dir)/sandbox.lib',
                  '<(libchromiumcontent_dir)/sandbox_helper_win.lib',
                  '<(libchromiumcontent_dir)/devtools_discovery.lib',
                  '<(libchromiumcontent_dir)/devtools_http_handler.lib',
                  '<(libchromiumcontent_dir)/http_server.lib',
                  '<(libchromiumcontent_dir)/desktop_capture.lib',
                  '<(libchromiumcontent_dir)/desktop_capture_differ_sse2.lib',
                  '<(libchromiumcontent_dir)/rtc_base.lib',
                  '<(libchromiumcontent_dir)/rtc_base_approved.lib',
                  '<(libchromiumcontent_dir)/system_wrappers.lib',
                  '<(libchromiumcontent_dir)/webrtc_common.lib',
                  '<(libchromiumcontent_dir)/libyuv.lib',
                  '<(libchromiumcontent_dir)/cdm_renderer.lib',
                  '<(libchromiumcontent_dir)/security_state.lib',
                  # Friends of pdf.lib:
                  '<(libchromiumcontent_dir)/pdf.lib',
                  '<(libchromiumcontent_dir)/ppapi_cpp_objects.lib',
                  '<(libchromiumcontent_dir)/ppapi_internal_module.lib',
                  '<(libchromiumcontent_dir)/libjpeg.lib',
                  '<(libchromiumcontent_dir)/pdfium.lib',
                  '<(libchromiumcontent_dir)/fdrm.lib',
                  '<(libchromiumcontent_dir)/formfiller.lib',
                  '<(libchromiumcontent_dir)/fpdfapi.lib',
                  '<(libchromiumcontent_dir)/fpdfdoc.lib',
                  '<(libchromiumcontent_dir)/fpdftext.lib',
                  '<(libchromiumcontent_dir)/fpdftext.lib',
                  '<(libchromiumcontent_dir)/fxcodec.lib',
                  '<(libchromiumcontent_dir)/fxcrt.lib',
                  '<(libchromiumcontent_dir)/fxedit.lib',
                  '<(libchromiumcontent_dir)/fxge.lib',
                  '<(libchromiumcontent_dir)/javascript.lib',
                  '<(libchromiumcontent_dir)/pdfwindow.lib',
                  '<(libchromiumcontent_dir)/bigint.lib',
                  '<(libchromiumcontent_dir)/fx_agg.lib',
                  '<(libchromiumcontent_dir)/fx_freetype.lib',
                  '<(libchromiumcontent_dir)/fx_lcms2.lib',
                  '<(libchromiumcontent_dir)/fx_libopenjpeg.lib',
                  '<(libchromiumcontent_dir)/fx_zlib.lib',
                ],
              },
            }, {
              # Link with system libraries.
              'link_settings': {
                'libraries': [
                  # Link with ffmpeg.
                  '<(libchromiumcontent_dir)/ffmpeg.dll',
                  # content_browser.gypi:
                  '-lsensorsapi.lib',
                  '-lportabledeviceguids.lib',
                  # content_common.gypi:
                  '-ld3d9.lib',
                  '-ld3d11.lib',
                  '-ldxva2.lib',
                  '-lstrmiids.lib',
                  '-lmf.lib',
                  '-lmfplat.lib',
                  '-lmfuuid.lib',
                  # media.gyp:
                  '-ldxguid.lib',
                  '-lmfreadwrite.lib',
                  '-lmfuuid.lib',
                ],
                'msvs_settings': {
                  'VCLinkerTool': {
                    'AdditionalDependencies': [
                      'advapi32.lib',
                      'dbghelp.lib',
                      'delayimp.lib',
                      'dwmapi.lib',
                      'gdi32.lib',
                      'netapi32.lib',
                      'oleacc.lib',
                      'user32.lib',
                      'usp10.lib',
                      'version.lib',
                      'winspool.lib',
                      'wtsapi32.lib',
                      # bluetooth.gyp:
                      'Bthprops.lib',
                      'BluetoothApis.lib',
                      # base.gyp:
                      'cfgmgr32.lib',
                      'powrprof.lib',
                      'setupapi.lib',
                      # net_common.gypi:
                      'crypt32.lib',
                      'dhcpcsvc.lib',
                      'rpcrt4.lib',
                      'secur32.lib',
                      'urlmon.lib',
                      'winhttp.lib',
                    ],
                    'DelayLoadDLLs': [
                      'wtsapi32.dll',
                      # content_common.gypi:
                      'd3d9.dll',
                      'd3d11.dll',
                      'dxva2.dll',
                      # media.gyp:
                      'mf.dll',
                      'mfplat.dll',
                      'mfreadwrite.dll',
                      # bluetooth.gyp:
                      'BluetoothApis.dll',
                      'Bthprops.cpl',
                      'setupapi.dll',
                      # base.gyp:
                      'cfgmgr32.dll',
                      'powrprof.dll',
                      'setupapi.dll',
                      # net_common.gypi:
                      'crypt32.dll',
                      'dhcpcsvc.dll',
                      'rpcrt4.dll',
                      'secur32.dll',
                      'urlmon.dll',
                      'winhttp.dll',
                      # windows runtime
                      'API-MS-WIN-CORE-WINRT-L1-1-0.DLL',
                      'API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL',
                    ],
                  },
                },
              },
            }],  # libchromiumcontent_component
          ],
        }],  # OS=="win"
      ],
    },
  ],
}
<|endoftext|>


<commit_before>from collections import defaultdict
from google.appengine.ext import deferred
from google.appengine.ext import ndb
from helpers.cache_clearer import CacheClearer

class ManipulatorBase(object):
    """
    Provides a basic framework for manipulating db models.
    Ideally, all db read/writes would go through manipulators.
    """

    BATCH_SIZE = 500

    @classmethod
    def delete_keys(cls, model_keys):
        models = [model_key.get() for model_key in model_keys]
        cls.delete(models)

    @classmethod
    def delete(self, models, run_post_delete_hook=True):
        models = filter(None, self.listify(models))
        keys = [model.key for model in models]
        ndb.delete_multi(keys)
        for model in models:
            model.dirty = True
            self._computeAndSaveAffectedReferences(model)
        if run_post_delete_hook:
            self.runPostDeleteHook(models)
        self._clearCache(models)

    @classmethod
    def getCacheKeysAndControllers(cls, affected_refs):
        """
        Child classes should replace method with appropriate call to CacheClearer.
        """
        return []

    @classmethod
    def _clearCache(cls, models):
        to_clear = defaultdict(set)
        for model in models:
            if hasattr(model, '_affected_references') and getattr(model, 'dirty', False):
                for cache_key, controller in cls.getCacheKeysAndControllers(model._affected_references):
                    to_clear[controller].add(cache_key)
            if hasattr(model, 'dirty'):
                model.dirty = False

        for controller, cache_keys in to_clear.items():
            controller.delete_cache_multi(cache_keys)

    @classmethod
    def listify(self, thing):
        if not isinstance(thing, list):
            return [thing]
        else:
            return thing

    @classmethod
    def delistify(self, things):
        if len(things) == 0:
            return None
        if len(things) == 1:
            return things.pop()
        else:
            return things

    @classmethod
    def _computeAndSaveAffectedReferences(cls, old_model, new_model=None):
        """
        This method is called whenever a model may potentially be created or updated.
        Stores the affected references in the original instance of the model.
        """
        if hasattr(old_model, '_affected_references'):
            for attr in old_model._affected_references.keys():
                for a in [old_model, new_model] if new_model is not None else [old_model]:
                    val = cls.listify(getattr(a, attr))
                    old_model._affected_references[attr] = old_model._affected_references[attr].union(val)

    @classmethod
    def createOrUpdate(self, new_models, auto_union=True, run_post_update_hook=True):
        """
        Given a model or list of models, either insert them into the database, or update
        existing models with the same key.
        Once inserted or updated, the model can be marked not dirty.
        """
        models = self.listify(self.findOrSpawn(self.listify(new_models), auto_union=auto_union))
        models_to_put = [model for model in models if getattr(model, "dirty", False)]
        ndb.put_multi(models_to_put)
        self._clearCache(models)
        if run_post_update_hook:
            self.runPostUpdateHook(models_to_put)
        return self.delistify(models)

    @classmethod
    def findOrSpawn(self, new_models, auto_union=True):
        """"
        Check if a model or models currently exists in the database based on
        key_name. Doesn't put models.
        If it does, update it and give it back. If it does not, give it back.
        """
        new_models = self.listify(new_models)
        old_models = ndb.get_multi([ndb.Key(type(model).__name__, model.key_name) for model in new_models])
        new_models = [self.updateMergeBase(new_model, old_model, auto_union=auto_union) for (new_model, old_model) in zip(new_models, old_models)]
        return self.delistify(new_models)

    @classmethod
    def updateMergeBase(self, new_model, old_model, auto_union=True):
        """
        Given an "old" and a "new" model object, replace the fields in the
        "old" one that are present in the "new" one, but keep fields from
        the "old" one that are null or the empty list in the "new" one.
        """
        if old_model is None:
            new_model.dirty = True
            self._computeAndSaveAffectedReferences(new_model)
            return new_model

        self._computeAndSaveAffectedReferences(old_model, new_model)
        return self.updateMerge(new_model, old_model, auto_union=auto_union)

    @classmethod
    def updateMerge(self, new_model, old_model, auto_union=True):
        """
        Child classes should replace with method with specific merging logic
        """
        raise NotImplementedError("No updateMerge method!")

    @classmethod
    def runPostDeleteHook(cls, models):
        """
        Asynchronously runs the manipulator's post delete hook if available.
        """
        post_delete_hook = getattr(cls, "postDeleteHook", None)
        if callable(post_delete_hook):
            deferred.defer(post_delete_hook, models, _queue="post-update-hooks")

    @classmethod
    def runPostUpdateHook(cls, models):
        """
        Asynchronously runs the manipulator's post update hook if available.
        """
        post_update_hook = getattr(cls, "postUpdateHook", None)
        if callable(post_update_hook):
            updated_attrs = [model._updated_attrs if hasattr(model, '_updated_attrs') else [] for model in models]
            deferred.defer(post_update_hook, models, updated_attrs, _queue="post-update-hooks")
<commit_msg>only call post hook if there are upated models<commit_after>from collections import defaultdict
from google.appengine.ext import deferred
from google.appengine.ext import ndb
from helpers.cache_clearer import CacheClearer

class ManipulatorBase(object):
    """
    Provides a basic framework for manipulating db models.
    Ideally, all db read/writes would go through manipulators.
    """

    BATCH_SIZE = 500

    @classmethod
    def delete_keys(cls, model_keys):
        models = [model_key.get() for model_key in model_keys]
        cls.delete(models)

    @classmethod
    def delete(self, models, run_post_delete_hook=True):
        models = filter(None, self.listify(models))
        keys = [model.key for model in models]
        ndb.delete_multi(keys)
        for model in models:
            model.dirty = True
            self._computeAndSaveAffectedReferences(model)
        if run_post_delete_hook:
            self.runPostDeleteHook(models)
        self._clearCache(models)

    @classmethod
    def getCacheKeysAndControllers(cls, affected_refs):
        """
        Child classes should replace method with appropriate call to CacheClearer.
        """
        return []

    @classmethod
    def _clearCache(cls, models):
        to_clear = defaultdict(set)
        for model in models:
            if hasattr(model, '_affected_references') and getattr(model, 'dirty', False):
                for cache_key, controller in cls.getCacheKeysAndControllers(model._affected_references):
                    to_clear[controller].add(cache_key)
            if hasattr(model, 'dirty'):
                model.dirty = False

        for controller, cache_keys in to_clear.items():
            controller.delete_cache_multi(cache_keys)

    @classmethod
    def listify(self, thing):
        if not isinstance(thing, list):
            return [thing]
        else:
            return thing

    @classmethod
    def delistify(self, things):
        if len(things) == 0:
            return None
        if len(things) == 1:
            return things.pop()
        else:
            return things

    @classmethod
    def _computeAndSaveAffectedReferences(cls, old_model, new_model=None):
        """
        This method is called whenever a model may potentially be created or updated.
        Stores the affected references in the original instance of the model.
        """
        if hasattr(old_model, '_affected_references'):
            for attr in old_model._affected_references.keys():
                for a in [old_model, new_model] if new_model is not None else [old_model]:
                    val = cls.listify(getattr(a, attr))
                    old_model._affected_references[attr] = old_model._affected_references[attr].union(val)

    @classmethod
    def createOrUpdate(self, new_models, auto_union=True, run_post_update_hook=True):
        """
        Given a model or list of models, either insert them into the database, or update
        existing models with the same key.
        Once inserted or updated, the model can be marked not dirty.
        """
        models = self.listify(self.findOrSpawn(self.listify(new_models), auto_union=auto_union))
        models_to_put = [model for model in models if getattr(model, "dirty", False)]
        ndb.put_multi(models_to_put)
        self._clearCache(models)
        if run_post_update_hook:
            self.runPostUpdateHook(models_to_put)
        return self.delistify(models)

    @classmethod
    def findOrSpawn(self, new_models, auto_union=True):
        """"
        Check if a model or models currently exists in the database based on
        key_name. Doesn't put models.
        If it does, update it and give it back. If it does not, give it back.
        """
        new_models = self.listify(new_models)
        old_models = ndb.get_multi([ndb.Key(type(model).__name__, model.key_name) for model in new_models])
        new_models = [self.updateMergeBase(new_model, old_model, auto_union=auto_union) for (new_model, old_model) in zip(new_models, old_models)]
        return self.delistify(new_models)

    @classmethod
    def updateMergeBase(self, new_model, old_model, auto_union=True):
        """
        Given an "old" and a "new" model object, replace the fields in the
        "old" one that are present in the "new" one, but keep fields from
        the "old" one that are null or the empty list in the "new" one.
        """
        if old_model is None:
            new_model.dirty = True
            self._computeAndSaveAffectedReferences(new_model)
            return new_model

        self._computeAndSaveAffectedReferences(old_model, new_model)
        return self.updateMerge(new_model, old_model, auto_union=auto_union)

    @classmethod
    def updateMerge(self, new_model, old_model, auto_union=True):
        """
        Child classes should replace with method with specific merging logic
        """
        raise NotImplementedError("No updateMerge method!")

    @classmethod
    def runPostDeleteHook(cls, models):
        """
        Asynchronously runs the manipulator's post delete hook if available.
        """
        if models:
            post_delete_hook = getattr(cls, "postDeleteHook", None)
            if callable(post_delete_hook):
                deferred.defer(post_delete_hook, models, _queue="post-update-hooks")

    @classmethod
    def runPostUpdateHook(cls, models):
        """
        Asynchronously runs the manipulator's post update hook if available.
        """
        if models:
            post_update_hook = getattr(cls, "postUpdateHook", None)
            if callable(post_update_hook):
                updated_attrs = [model._updated_attrs if hasattr(model, '_updated_attrs') else [] for model in models]
                deferred.defer(post_update_hook, models, updated_attrs, _queue="post-update-hooks")
<|endoftext|>


<commit_before># coding=utf-8
import logging

from .jira import Jira

log = logging.getLogger(__name__)

class Jira8(Jira):
    # methods migrated into main module
<commit_msg>Static method for the future deprecated modules (#395)<commit_after># coding=utf-8
import logging

from .jira import Jira

log = logging.getLogger(__name__)

class Jira8(Jira):
    # methods migrated into main module
    @staticmethod
    def print_module_name():
        print(__name__)
<|endoftext|>