<commit_before>import os
import sys
from setuptools import setup

INSTALL_REQUIRES = ['requests >=1.0.3', 'boto >=2.45.0', 'six >=1.2.0', 'urllib3 >= 1.0.2', 'inflection >= 0.3.1']
if sys.version_info < (2, 7, 0):
    INSTALL_REQUIRES.append('argparse>=1.1')

def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name="qds_sdk",
    version="1.15.2",
    author="Qubole",
    author_email="dev@qubole.com",
    description=("Python SDK for coding to the Qubole Data Service API"),
    license="Apache License 2.0",
    keywords="qubole sdk api",
    url="https://github.com/qubole/qds-sdk-py",
    packages=['qds_sdk', 'qds_sdk/cloud'],
    scripts=['bin/qds.py'],
    install_requires=INSTALL_REQUIRES,
    long_description=read('README.rst'),
    python_requires='>=2.7',
    classifiers=[
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: Apache Software License",
        "Programming Language :: Python",
        "Programming Language :: Python :: 2",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.3",
        "Programming Language :: Python :: 3.4"
    ]
    )
<commit_msg>SDK-401: Fix inflection version upgrade on basis of python version (#316)<commit_after>import os
import sys
from setuptools import setup

INSTALL_REQUIRES = ['requests >=1.0.3', 'boto >=2.45.0', 'six >=1.2.0', 'urllib3 >= 1.0.2']

if sys.version_info < (2, 7, 0):
    INSTALL_REQUIRES.append('argparse>=1.1')
if sys.version_info < (3, 5):
    INSTALL_REQUIRES.append('inflection==0.3.1')
else:
    INSTALL_REQUIRES.append('inflection>=0.3.1')

def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name="qds_sdk",
    version="1.15.2",
    author="Qubole",
    author_email="dev@qubole.com",
    description=("Python SDK for coding to the Qubole Data Service API"),
    license="Apache License 2.0",
    keywords="qubole sdk api",
    url="https://github.com/qubole/qds-sdk-py",
    packages=['qds_sdk', 'qds_sdk/cloud'],
    scripts=['bin/qds.py'],
    install_requires=INSTALL_REQUIRES,
    long_description=read('README.rst'),
    python_requires='>=2.7',
    classifiers=[
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: Apache Software License",
        "Programming Language :: Python",
        "Programming Language :: Python :: 2",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.3",
        "Programming Language :: Python :: 3.4"
    ]
    )
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function

import os
import time

import numpy as np
import tensorflow as tf
from six.moves import range

from engine.input_buffer import TrainEvalInputBuffer
from engine.spatial_location_check import SpatialLocationCheckLayer
from engine.selective_sampler import SelectiveSampler
from engine.uniform_sampler import UniformSampler
from layer.loss import LossFunction
from utilities import misc_common as util
from utilities.input_placeholders import ImagePatch
import engine.logging

np.random.seed(seed=int(time.time()))

def run(net_class, param, volume_loader, device_str):
    # construct graph
    graph = tf.Graph()
    with graph.as_default(), tf.device('/cpu:0'):
        # defines a training element
        patch_holder = ImagePatch(
            spatial_rank=param.spatial_rank,
            image_size=param.image_size,
            label_size=param.label_size,
            weight_map_size=param.w_map_size,
            image_dtype=tf.float32,
            label_dtype=tf.int64,
            weight_map_dtype=tf.float32,
            num_image_modality=volume_loader.num_modality(0),
            num_label_modality=volume_loader.num_modality(1),
            num_weight_map=volume_loader.num_modality(2))
        # defines data augmentation for training
        augmentations = []
        if param.rotation:
            from layer.rand_rotation import RandomRotationLayer
            augmentations.append(RandomRotationLayer(
                min_angle=param.min_angle,
                max_angle=param.max_angle))
        if param.spatial_scaling:
            from layer.rand_spatial_scaling import RandomSpatialScalingLayer
            augmentations.append(RandomSpatialScalingLayer(
                min_percentage=param.min_percentage,
                max_percentage=param.max_percentage))
        # defines how to generate samples of the training element from volume
        with tf.name_scope('Sampling'):
            if param.window_sampling == 'uniform':
                sampler = UniformSampler(patch=patch_holder,
                                        volume_loader=volume_loader,
                                        patch_per_volume=param.sample_per_volume,
                                        data_augmentation_methods=augmentations,
                                        name='uniform_sampler')
            elif param.window_sampling == 'selective':
                # TODO check param, this is for segmentation problems only
                spatial_location_check = SpatialLocationCheckLayer(
                    compulsory=((0), (0)),
                    minimum_ratio=param.min_sampling_ratio,
                    min_numb_labels=param.min_numb_labels,
                    padding=param.border,
                    name='spatial_location_check')
                sampler = SelectiveSampler(
                    patch=patch_holder,
                    volume_loader=volume_loader,
                    spatial_location_check=spatial_location_check,
                    data_augmentation_methods=None,
                    patch_per_volume=param.sample_per_volume,
                    name="selective_sampler")
        w_regularizer = None
        b_regularizer = None
        if param.reg_type.lower() == 'l2':
            from tensorflow.contrib.layers.python.layers import regularizers
            w_regularizer = regularizers.l2_regularizer(param.decay)
            b_regularizer = regularizers.l2_regularizer(param.decay)
        elif param.reg_type.lower() == 'l1':
            from tensorflow.contrib.layers.python.layers import regularizers
            w_regularizer = regularizers.l1_regularizer(param.decay)
            b_regularizer = regularizers.l1_regularizer(param.decay)
        net = net_class(num_classes=param.num_classes,
                            w_regularizer=w_regularizer,
                            b_regularizer=b_regularizer,
                            acti_func=param.activation_function)
        loss_func = LossFunction(n_class=param.num_classes,
                                loss_type=param.loss_type)
        # construct train queue
        with tf.name_scope('DataQueue'):
            train_batch_runner = TrainEvalInputBuffer(
                batch_size=param.batch_size,
                capacity=max(param.queue_length, param.batch_size),
                sampler=sampler,
                shuffle=True)
        # optimizer
        with tf.name_scope('Optimizer'):
            train_step = tf.train.AdamOptimizer(learning_rate=param.lr)
        tower_grads = []
        train_pairs = train_batch_runner.pop_batch_op
        images, labels = train_pairs['Sampling/images'], train_pairs['Sampling/labels']
        if "weight_maps" in train_pairs:
            weight_maps = train_pairs['Sampling/weight_maps']
        else:
            weight_maps = None
        # Scalar summaries for the console are averaged over GPU runs
        console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
        console_outputs_cache=console_outputs[:]
        del console_outputs[:]
        tower_console_outputs=[]

        for i in range(0, max(param.num_gpus, 1)):
            with tf.device("/{}:{}".format(device_str, i)):
                predictions = net(images, is_training=True)
                with tf.name_scope('Loss'):
                    loss = loss_func(predictions, labels, weight_maps)
                    if param.decay > 0:
                        reg_losses = graph.get_collection(
                            tf.GraphKeys.REGULARIZATION_LOSSES)
                        reg_loss = tf.reduce_mean([tf.reduce_mean(reg_loss)
                                                for reg_loss in reg_losses])
                        loss = loss + reg_loss
                tf.summary.scalar('loss',loss,[engine.logging.CONSOLE,engine.logging.LOG])

                ##################
                # This should probably be refactored into an application class
                # Averages are in name_scope for Tensorboard naming; summaries are outside for console naming
                with tf.name_scope('ConsoleLogging'):
                    logs=[]
                    if param.application_type == 'segmentation':
                        # TODO compute miss for dfferent target types
                        logs.append(['miss', tf.reduce_mean(tf.cast(
                              tf.not_equal(tf.argmax(predictions, -1), labels[..., 0]),
                              dtype=tf.float32))])
                for tag,val in logs:
                    tf.summary.scalar(tag,val,[engine.logging.CONSOLE,engine.logging.LOG])
                ##################

                # record and clear summaries
                console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
                tower_console_outputs.append(console_outputs[:])
                del console_outputs[:]

                with tf.name_scope('ComputeGradients'):
                    grads = train_step.compute_gradients(loss)
                tower_grads.append(grads)
                # note: only use batch stats from one GPU for batch_norm
                if i == 0:
                    bn_updates = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
        with tf.name_scope('AccumulateGradients'):
            ave_grads = util.average_grads(tower_grads)
            apply_grad_op = train_step.apply_gradients(ave_grads)

        # Add averaged summaries
        console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
        console_outputs+=console_outputs_cache
        if len(tower_console_outputs)>1:
            # Averages are in name_scope for Tensorboard naming; summaries are outside for console naming
            with tf.name_scope('AccumulateConsoleLogs'):
                averaged_summaries=[]
                for replicated_output in zip(*tower_console_outputs):
                    averaged_summaries.append([replicated_output[0].op.name+'_avg',tf.reduce_mean([o.op.inputs[1] for o in replicated_output])])
            for tag,avg in averaged_summaries:
                tf.summary.scalar(tag, avg,[engine.logging.CONSOLE,engine.logging.LOG])
        # Track the moving averages of all trainable variables.
        with tf.name_scope('MovingAverages'):
            variable_averages = tf.train.ExponentialMovingAverage(0.9)
            var_averages_op = variable_averages.apply(tf.trainable_variables())
            # batch norm variables moving mean and var
            batchnorm_updates_op = tf.group(*bn_updates)
        # primary operations
        init_op = tf.global_variables_initializer()
        train_op = tf.group(apply_grad_op,
                            var_averages_op,
                            batchnorm_updates_op)
        logged_summaries = list(set([s for c in [engine.logging.LOG,engine.logging.CONSOLE] for s in tf.get_collection(c)]))
        write_summary_op = tf.summary.merge(logged_summaries)
        # saver
        variables_to_restore = variable_averages.variables_to_restore()
        saver = tf.train.Saver(max_to_keep=param.max_checkpoints, var_list=variables_to_restore)
        tf.Graph.finalize(graph)
    # run session
    config = tf.ConfigProto()
    config.log_device_placement = False
    config.allow_soft_placement = True
    # config.gpu_options.allow_growth = True
    start_time = time.time()
    with tf.Session(config=config, graph=graph) as sess:
        # prepare output directory
        if not os.path.exists(os.path.join(param.model_dir, 'models')):
            os.makedirs(os.path.join(param.model_dir, 'models'))
        root_dir = os.path.abspath(param.model_dir)
        # start or load session
        ckpt_name = os.path.join(root_dir, 'models', 'model.ckpt')
        if param.starting_iter > 0:
            model_str = '{}-{}'.format(ckpt_name, param.starting_iter)
            saver.restore(sess, model_str)
            print('Loading from {}...'.format(model_str))
        else:
            sess.run(init_op)
            print('Weights from random initialisations...')
        coord = tf.train.Coordinator()
        writer = tf.summary.FileWriter(os.path.join(root_dir, 'logs'),
                                       sess.graph)
        try:
            print('Filling the queue (this can take a few minutes)')
            train_batch_runner.run_threads(sess, coord, param.num_threads)
            for i in range(param.max_iter - param.starting_iter):
                local_time = time.time()
                if coord.should_stop():
                    break
                current_iter = i + param.starting_iter
                ops_to_run=[train_op]
                console_summaries=tf.get_collection(engine.logging.CONSOLE)
                ops_to_run += console_summaries
                if (current_iter % 20) == 0:
                    ops_to_run += [write_summary_op]
                values = sess.run(ops_to_run)[1:]
                if (current_iter % 20) == 0:
                    writer.add_summary(values.pop(), current_iter)
                summary_string = ''.join([engine.logging.console_summary_string(v) for v in values])
                iter_time = time.time() - local_time
                print(('iter {:d}{}, ({:.3f}s)').format(
                    current_iter, summary_string, iter_time))
                if (current_iter % param.save_every_n) == 0 and i > 0:
                    saver.save(sess, ckpt_name, global_step=current_iter)
                    print('Iter {} model saved at {}'.format(
                        current_iter, ckpt_name))
        except KeyboardInterrupt:
            print('User cancelled training')
        except tf.errors.OutOfRangeError as e:
            pass
        except Exception:
            import sys, traceback
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(
                exc_type, exc_value, exc_traceback, file=sys.stdout)
        finally:
            saver.save(sess, ckpt_name, global_step=param.max_iter)
            print('Last iteration model saved at {}'.format(ckpt_name))
            print('training.py (time in second) {:.2f}'.format(
                time.time() - start_time))
            train_batch_runner.close_all()<commit_msg>Correct console logging in training.<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function

import os
import time

import numpy as np
import tensorflow as tf
from six.moves import range

from engine.input_buffer import TrainEvalInputBuffer
from engine.spatial_location_check import SpatialLocationCheckLayer
from engine.selective_sampler import SelectiveSampler
from engine.uniform_sampler import UniformSampler
from layer.loss import LossFunction
from utilities import misc_common as util
from utilities.input_placeholders import ImagePatch
import engine.logging

np.random.seed(seed=int(time.time()))

def run(net_class, param, volume_loader, device_str):
    # construct graph
    graph = tf.Graph()
    with graph.as_default(), tf.device('/cpu:0'):
        # defines a training element
        patch_holder = ImagePatch(
            spatial_rank=param.spatial_rank,
            image_size=param.image_size,
            label_size=param.label_size,
            weight_map_size=param.w_map_size,
            image_dtype=tf.float32,
            label_dtype=tf.int64,
            weight_map_dtype=tf.float32,
            num_image_modality=volume_loader.num_modality(0),
            num_label_modality=volume_loader.num_modality(1),
            num_weight_map=volume_loader.num_modality(2))
        # defines data augmentation for training
        augmentations = []
        if param.rotation:
            from layer.rand_rotation import RandomRotationLayer
            augmentations.append(RandomRotationLayer(
                min_angle=param.min_angle,
                max_angle=param.max_angle))
        if param.spatial_scaling:
            from layer.rand_spatial_scaling import RandomSpatialScalingLayer
            augmentations.append(RandomSpatialScalingLayer(
                min_percentage=param.min_percentage,
                max_percentage=param.max_percentage))
        # defines how to generate samples of the training element from volume
        with tf.name_scope('Sampling'):
            if param.window_sampling == 'uniform':
                sampler = UniformSampler(patch=patch_holder,
                                        volume_loader=volume_loader,
                                        patch_per_volume=param.sample_per_volume,
                                        data_augmentation_methods=augmentations,
                                        name='uniform_sampler')
            elif param.window_sampling == 'selective':
                # TODO check param, this is for segmentation problems only
                spatial_location_check = SpatialLocationCheckLayer(
                    compulsory=((0), (0)),
                    minimum_ratio=param.min_sampling_ratio,
                    min_numb_labels=param.min_numb_labels,
                    padding=param.border,
                    name='spatial_location_check')
                sampler = SelectiveSampler(
                    patch=patch_holder,
                    volume_loader=volume_loader,
                    spatial_location_check=spatial_location_check,
                    data_augmentation_methods=None,
                    patch_per_volume=param.sample_per_volume,
                    name="selective_sampler")
        w_regularizer = None
        b_regularizer = None
        if param.reg_type.lower() == 'l2':
            from tensorflow.contrib.layers.python.layers import regularizers
            w_regularizer = regularizers.l2_regularizer(param.decay)
            b_regularizer = regularizers.l2_regularizer(param.decay)
        elif param.reg_type.lower() == 'l1':
            from tensorflow.contrib.layers.python.layers import regularizers
            w_regularizer = regularizers.l1_regularizer(param.decay)
            b_regularizer = regularizers.l1_regularizer(param.decay)
        net = net_class(num_classes=param.num_classes,
                            w_regularizer=w_regularizer,
                            b_regularizer=b_regularizer,
                            acti_func=param.activation_function)
        loss_func = LossFunction(n_class=param.num_classes,
                                loss_type=param.loss_type)
        # construct train queue
        with tf.name_scope('DataQueue'):
            train_batch_runner = TrainEvalInputBuffer(
                batch_size=param.batch_size,
                capacity=max(param.queue_length, param.batch_size),
                sampler=sampler,
                shuffle=True)
        # optimizer
        with tf.name_scope('Optimizer'):
            train_step = tf.train.AdamOptimizer(learning_rate=param.lr)
        tower_grads = []
        train_pairs = train_batch_runner.pop_batch_op
        images, labels = train_pairs['Sampling/images'], train_pairs['Sampling/labels']
        if "weight_maps" in train_pairs:
            weight_maps = train_pairs['Sampling/weight_maps']
        else:
            weight_maps = None
        # Scalar summaries for the console are averaged over GPU runs
        console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
        console_outputs_cache=console_outputs[:]
        del console_outputs[:]
        tower_console_outputs=[]

        for i in range(0, max(param.num_gpus, 1)):
            with tf.device("/{}:{}".format(device_str, i)):
                predictions = net(images, is_training=True)
                with tf.name_scope('Loss'):
                    loss = loss_func(predictions, labels, weight_maps)
                    if param.decay > 0:
                        reg_losses = graph.get_collection(
                            tf.GraphKeys.REGULARIZATION_LOSSES)
                        reg_loss = tf.reduce_mean([tf.reduce_mean(reg_loss)
                                                for reg_loss in reg_losses])
                        loss = loss + reg_loss

                ##################
                # This should probably be refactored into an application class
                # Averages are in name_scope for Tensorboard naming; summaries are outside for console naming
                with tf.name_scope('ConsoleLogging'):
                    logs=[['loss',loss]]
                    if param.application_type == 'segmentation':
                        # TODO compute miss for dfferent target types
                        logs.append(['miss', tf.reduce_mean(tf.cast(
                              tf.not_equal(tf.argmax(predictions, -1), labels[..., 0]),
                              dtype=tf.float32))])
                for tag,val in logs:
                    tf.summary.scalar(tag,val,[engine.logging.CONSOLE,engine.logging.LOG])
                ##################

                # record and clear summaries
                console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
                tower_console_outputs.append(console_outputs[:])
                del console_outputs[:]

                with tf.name_scope('ComputeGradients'):
                    grads = train_step.compute_gradients(loss)
                tower_grads.append(grads)
                # note: only use batch stats from one GPU for batch_norm
                if i == 0:
                    bn_updates = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
        with tf.name_scope('AccumulateGradients'):
            ave_grads = util.average_grads(tower_grads)
            apply_grad_op = train_step.apply_gradients(ave_grads)

        # Add averaged summaries
        console_outputs=graph.get_collection_ref(engine.logging.CONSOLE)
        console_outputs+=console_outputs_cache
        if len(tower_console_outputs)>1:
            # Averages are in name_scope for Tensorboard naming; summaries are outside for console naming
            with tf.name_scope('AccumulateConsoleLogs'):
                averaged_summaries=[]
                for replicated_output in zip(*tower_console_outputs):
                    averaged_summaries.append([replicated_output[0].op.name+'_avg',tf.reduce_mean([o.op.inputs[1] for o in replicated_output])])
            for tag,avg in averaged_summaries:
                tf.summary.scalar(tag, avg,[engine.logging.CONSOLE,engine.logging.LOG])
        else:
            console_outputs+=tower_console_outputs[0]
        # Track the moving averages of all trainable variables.
        with tf.name_scope('MovingAverages'):
            variable_averages = tf.train.ExponentialMovingAverage(0.9)
            var_averages_op = variable_averages.apply(tf.trainable_variables())
            # batch norm variables moving mean and var
            batchnorm_updates_op = tf.group(*bn_updates)
        # primary operations
        init_op = tf.global_variables_initializer()
        train_op = tf.group(apply_grad_op,
                            var_averages_op,
                            batchnorm_updates_op)
        logged_summaries = list(set([s for c in [engine.logging.LOG,engine.logging.CONSOLE] for s in tf.get_collection(c)]))
        write_summary_op = tf.summary.merge(logged_summaries)
        # saver
        variables_to_restore = variable_averages.variables_to_restore()
        saver = tf.train.Saver(max_to_keep=param.max_checkpoints, var_list=variables_to_restore)
        tf.Graph.finalize(graph)
    # run session
    config = tf.ConfigProto()
    config.log_device_placement = False
    config.allow_soft_placement = True
    # config.gpu_options.allow_growth = True
    start_time = time.time()
    with tf.Session(config=config, graph=graph) as sess:
        # prepare output directory
        if not os.path.exists(os.path.join(param.model_dir, 'models')):
            os.makedirs(os.path.join(param.model_dir, 'models'))
        root_dir = os.path.abspath(param.model_dir)
        # start or load session
        ckpt_name = os.path.join(root_dir, 'models', 'model.ckpt')
        if param.starting_iter > 0:
            model_str = '{}-{}'.format(ckpt_name, param.starting_iter)
            saver.restore(sess, model_str)
            print('Loading from {}...'.format(model_str))
        else:
            sess.run(init_op)
            print('Weights from random initialisations...')
        coord = tf.train.Coordinator()
        writer = tf.summary.FileWriter(os.path.join(root_dir, 'logs'),
                                       sess.graph)
        try:
            print('Filling the queue (this can take a few minutes)')
            train_batch_runner.run_threads(sess, coord, param.num_threads)
            for i in range(param.max_iter - param.starting_iter):
                local_time = time.time()
                if coord.should_stop():
                    break
                current_iter = i + param.starting_iter
                ops_to_run=[train_op]
                console_summaries=tf.get_collection(engine.logging.CONSOLE)
                ops_to_run += console_summaries
                if (current_iter % 20) == 0:
                    ops_to_run += [write_summary_op]
                values = sess.run(ops_to_run)[1:]
                if (current_iter % 20) == 0:
                    writer.add_summary(values.pop(), current_iter)
                summary_string = ''.join([engine.logging.console_summary_string(v) for v in values])
                iter_time = time.time() - local_time
                print(('iter {:d}{}, ({:.3f}s)').format(
                    current_iter, summary_string, iter_time))
                if (current_iter % param.save_every_n) == 0 and i > 0:
                    saver.save(sess, ckpt_name, global_step=current_iter)
                    print('Iter {} model saved at {}'.format(
                        current_iter, ckpt_name))
        except KeyboardInterrupt:
            print('User cancelled training')
        except tf.errors.OutOfRangeError as e:
            pass
        except Exception:
            import sys, traceback
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(
                exc_type, exc_value, exc_traceback, file=sys.stdout)
        finally:
            saver.save(sess, ckpt_name, global_step=param.max_iter)
            print('Last iteration model saved at {}'.format(ckpt_name))
            print('training.py (time in second) {:.2f}'.format(
                time.time() - start_time))
            train_batch_runner.close_all()<|endoftext|>


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

import os
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

def publish():
    """Publishes module to The Cheeseshop."""

    os.system('python setup.py sdist upload')

if 'publish' in sys.argv:
    publish()
    sys.exit()

setup(
    name='pystache',
    version='0.3.1',
    description='Mustache for Python',
    long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(),
    author='Chris Wanstrath',
    author_email='chris@ozmm.org',
    url='http://github.com/defunkt/pystache',
    packages=['pystache'],
    license='MIT',
    classifiers = (
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python",
        "Programming Language :: Python :: 2.5",
        "Programming Language :: Python :: 2.6"
    )
)

<commit_msg>consistent string types<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

def publish():
    """Publishes module to The Cheeseshop."""

    os.system('python setup.py sdist upload')

if 'publish' in sys.argv:
    publish()
    sys.exit()

setup(
    name='pystache',
    version='0.3.1',
    description='Mustache for Python',
    long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(),
    author='Chris Wanstrath',
    author_email='chris@ozmm.org',
    url='http://github.com/defunkt/pystache',
    packages=['pystache'],
    license='MIT',
    classifiers = (
        'Development Status :: 4 - Beta',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.5',
        'Programming Language :: Python :: 2.6'
    )
)

<|endoftext|>


<commit_before># Copyright 2014 tsuru-circus authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

__version__ = "0.8.5"
<commit_msg>bump to 0.8.6.<commit_after># Copyright 2014 tsuru-circus authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

__version__ = "0.8.6"
<|endoftext|>


<commit_before>"""
.. module::
    :synopsis:

.. moduleauthor:: Vitaly Kovalev <intscorpio@gmail.com>
"""
from shutil import copytree, rmtree
from os.path import exists, splitext, join
import tempfile
import json
import glob
from subprocess import CalledProcessError

from engine.util import local_path, hdfs_path, proj_root, hdfs_prefix, cmd_check, cmd, SMConfig, logger

class WorkDir(object):
    """ Provides an access to a work directory for a processed dataset

    Args
    ----
    ds_name : str
        Dataset name (alias)
    data_dir_path : str
        Dataset config
    """
    def __init__(self, ds_name, data_dir_path=None):
        self.sm_config = SMConfig.get_conf()
        self.ds_name = ds_name
        self.data_dir_path = data_dir_path
        self.path = join(self.data_dir_path, ds_name)
        self.ds_config = None

    # TODO: add tests
    def drop_local_work_dir(self):
        try:
            cmd_check('rm -rf {}', self.path)
        except CalledProcessError as e:
            logger.warning('Deleting interim local data files error: {}', e.message)

    def clean_work_dirs(self):
        try:
            cmd_check('rm -rf {}', self.path)
            if not self.sm_config['fs']['local']:
                cmd_check(hdfs_prefix() + '-rm -R {}', hdfs_path(self.path))
        except CalledProcessError as e:
            logger.warning('Deleting interim data files error: {}', e.message)

    def copy_input_data(self, input_data_path):
        """ Copy imzML/ibd/config files from input path to a dataset work directory

        Args
        ----
        input_data_path : str
            Path to input files
        """
        if exists(self.path):
            logger.info('Path %s already exists', self.path)
            # rmtree(self.path)
        else:
            logger.info('Copying %s to %s', input_data_path, self.path)

            # TODO: add support for S3 paths
            if input_data_path.startswith('http'):
                tmp_path = join(self.data_dir_path, 'tmp')
                cmd_check('mkdir -p {}', tmp_path)

                tmp_zip = tempfile.mkstemp(dir=tmp_path, suffix='.zip')[1]
                cmd_check('wget {} -O {}', input_data_path, tmp_zip)
                cmd_check('mkdir -p {}', self.path)
                cmd_check('unzip {} -d {}', tmp_zip, self.path)
            else:
                copytree(input_data_path, self.path)

    def upload_data_to_hdfs(self):
        """ If non local file system is used uploads plain text data files to it """
        logger.info('Coping DS text file to HDFS...')
        return_code = cmd(hdfs_prefix() + '-test -e {}', hdfs_path(self.path))
        if return_code:
            cmd_check(hdfs_prefix() + '-mkdir -p {}', hdfs_path(self.path))
            cmd_check(hdfs_prefix() + '-copyFromLocal {} {}',
                      local_path(self.txt_path), hdfs_path(self.txt_path))
            cmd_check(hdfs_prefix() + '-copyFromLocal {} {}',
                      local_path(self.coord_path), hdfs_path(self.coord_path))

    @property
    def ds_config_path(self):
        return join(self.path, 'config.json')

    @property
    def imzml_path(self):
        return glob.glob(join(self.path, '*.imzML'))[0]

    @property
    def txt_path(self):
        return join(self.path, 'ds.txt')

    @property
    def coord_path(self):
        return join(self.path, 'ds_coord.txt')
<commit_msg>Always copy the dataset config to the work directory<commit_after>"""
.. module::
    :synopsis:

.. moduleauthor:: Vitaly Kovalev <intscorpio@gmail.com>
"""
from shutil import copytree, rmtree, copy
from os.path import exists, splitext, join
import tempfile
import json
import glob
from subprocess import CalledProcessError

from engine.util import local_path, hdfs_path, proj_root, hdfs_prefix, cmd_check, cmd, SMConfig, logger

class WorkDir(object):
    """ Provides an access to a work directory for a processed dataset

    Args
    ----
    ds_name : str
        Dataset name (alias)
    data_dir_path : str
        Dataset config
    """
    def __init__(self, ds_name, data_dir_path=None):
        self.sm_config = SMConfig.get_conf()
        self.ds_name = ds_name
        self.data_dir_path = data_dir_path
        self.path = join(self.data_dir_path, ds_name)
        self.ds_config = None

    # TODO: add tests
    def drop_local_work_dir(self):
        try:
            cmd_check('rm -rf {}', self.path)
        except CalledProcessError as e:
            logger.warning('Deleting interim local data files error: {}', e.message)

    def clean_work_dirs(self):
        try:
            cmd_check('rm -rf {}', self.path)
            if not self.sm_config['fs']['local']:
                cmd_check(hdfs_prefix() + '-rm -R {}', hdfs_path(self.path))
        except CalledProcessError as e:
            logger.warning('Deleting interim data files error: {}', e.message)

    def copy_input_data(self, input_data_path):
        """ Copy imzML/ibd/config files from input path to a dataset work directory

        Args
        ----
        input_data_path : str
            Path to input files
        """
        if exists(self.path):
            logger.info('Path %s already exists', self.path)
            copy(join(input_data_path, 'config.json'), self.path)
        else:
            logger.info('Copying %s to %s', input_data_path, self.ds_config_path)

            # TODO: add support for S3 paths
            if input_data_path.startswith('http'):
                tmp_path = join(self.data_dir_path, 'tmp')
                cmd_check('mkdir -p {}', tmp_path)

                tmp_zip = tempfile.mkstemp(dir=tmp_path, suffix='.zip')[1]
                cmd_check('wget {} -O {}', input_data_path, tmp_zip)
                cmd_check('mkdir -p {}', self.path)
                cmd_check('unzip {} -d {}', tmp_zip, self.path)
            else:
                copytree(input_data_path, self.path)

    def upload_data_to_hdfs(self):
        """ If non local file system is used uploads plain text data files to it """
        logger.info('Coping DS text file to HDFS...')
        return_code = cmd(hdfs_prefix() + '-test -e {}', hdfs_path(self.path))
        if return_code:
            cmd_check(hdfs_prefix() + '-mkdir -p {}', hdfs_path(self.path))
            cmd_check(hdfs_prefix() + '-copyFromLocal {} {}',
                      local_path(self.txt_path), hdfs_path(self.txt_path))
            cmd_check(hdfs_prefix() + '-copyFromLocal {} {}',
                      local_path(self.coord_path), hdfs_path(self.coord_path))

    @property
    def ds_config_path(self):
        return join(self.path, 'config.json')

    @property
    def imzml_path(self):
        return glob.glob(join(self.path, '*.imzML'))[0]

    @property
    def txt_path(self):
        return join(self.path, 'ds.txt')

    @property
    def coord_path(self):
        return join(self.path, 'ds_coord.txt')
<|endoftext|>


<commit_before>#!/usr/bin/env python
from distutils.core import setup
from pdfminer import __version__

setup(
    name = 'pdfminer',
    version = __version__,
    description = 'PDF parser and analyzer',
    long_description = '''PDFMiner is a tool for extracting information from PDF documents.
Unlike other PDF-related tools, it focuses entirely on getting
and analyzing text data. PDFMiner allows to obtain
the exact location of texts in a page, as well as
other information such as fonts or lines.
It includes a PDF converter that can transform PDF files
into other text formats (such as HTML). It has an extensible
PDF parser that can be used for other purposes instead of text analysis.''',
    license = 'MIT',
    author = 'Yusuke Shinyama',
    author_email = 'yusuke@shinyama.jp',
    url = 'http://github.com/euske/pdfminer',
    packages = [
        'pdfminer',
    ],
    package_data={
        'pdfminer': ['cmap/*.marshal.gz']
    },
    scripts=[
        'tools/pdf2txt.py',
        'tools/dumppdf.py',
        'tools/latin2ascii.py',
    ],
    keywords=[
        'pdf parser',
        'pdf converter',
        'layout analysis',
        'text mining'
    ],
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Topic :: Text Processing',
    ],
)
<commit_msg>Updated: setup.py<commit_after>#!/usr/bin/env python
from setuptools import setup
from pdfminer import __version__

setup(
    name = 'pdfminer',
    version = __version__,
    description = 'PDF parser and analyzer',
    long_description = '''PDFMiner is a tool for extracting information from PDF documents.
Unlike other PDF-related tools, it focuses entirely on getting
and analyzing text data. PDFMiner allows to obtain
the exact location of texts in a page, as well as
other information such as fonts or lines.
It includes a PDF converter that can transform PDF files
into other text formats (such as HTML). It has an extensible
PDF parser that can be used for other purposes instead of text analysis.''',
    license = 'MIT',
    author = 'Yusuke Shinyama',
    author_email = 'yusuke@shinyama.jp',
    url = 'http://github.com/euske/pdfminer',
    packages = [
        'pdfminer',
    ],
    package_data={
        'pdfminer': ['cmap/*.marshal.gz']
    },
    install_requires = [
        'pycryptdome',
    ],
    scripts=[
        'tools/pdf2txt.py',
        'tools/dumppdf.py',
        'tools/latin2ascii.py',
    ],
    keywords=[
        'pdf parser',
        'pdf converter',
        'layout analysis',
        'text mining'
    ],
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Topic :: Text Processing',
    ],
)
<|endoftext|>


<commit_before>from setuptools import setup, find_packages

__version__ = '0.1.0'

install_requires = (
    'requests'
    'websocket-client',
    'importlib',
    'slacker',
)

excludes = (
    '*test*',
    '*local_settings*',
)

setup(name='slackbot',
      version=__version__,
      license='BSD',
      description='A simpile chat bot for Slack',
      author='Shuai Lin',
      author_email='linshuai2012@gmail.com',
      url='http://github.com/lins05/slackbot',
      platforms=['Any'],
      packages=find_packages(exclude=excludes),
      install_requires=install_requires,
      classifiers=['Development Status :: 4 - Beta',
                   'License :: OSI Approved :: BSD License',
                   'Operating System :: OS Independent',
                   'Programming Language :: Python'],
      )
<commit_msg>bump version to 0.1.1<commit_after>from setuptools import setup, find_packages

__version__ = '0.1.1'

install_requires = (
    'requests'
    'websocket-client',
    'importlib',
    'slacker',
)

excludes = (
    '*test*',
    '*local_settings*',
)

setup(name='slackbot',
      version=__version__,
      license='BSD',
      description='A simpile chat bot for Slack',
      author='Shuai Lin',
      author_email='linshuai2012@gmail.com',
      url='http://github.com/lins05/slackbot',
      platforms=['Any'],
      packages=find_packages(exclude=excludes),
      install_requires=install_requires,
      classifiers=['Development Status :: 4 - Beta',
                   'License :: OSI Approved :: BSD License',
                   'Operating System :: OS Independent',
                   'Programming Language :: Python'],
      )
<|endoftext|>


<commit_before>import bz2
import re
import sys
import time
import hashlib
import urlparse
import urllib2
from cStringIO import StringIO
from os.path import abspath, expanduser, getmtime, isfile, join

from egginst import name_version_fn
from egginst.utils import human_bytes
from enstaller import __version__
from enstaller.verlib import NormalizedVersion, IrrationalVersionError

PY_VER = '%i.%i' % sys.version_info[:2]

def abs_expanduser(path):
    return abspath(expanduser(path))

def canonical(s):
    """
    return the canonical representations of a project name
    """
    # eventually (once Python 2.6 repo eggs are no longer supported), this
    # function should only return s.lower()
    s = s.lower()
    s = s.replace('-', '_')
    if s == 'tables':
        s = 'pytables'
    return s

def cname_fn(fn):
    return canonical(fn.split('-')[0])

def comparable_version(version):
    """
    Given a version string (e.g. '1.3.0.dev234'), return an object which
    allows correct comparison. For example:
        comparable_version('1.3.10') > comparable_version('1.3.8')  # True
    whereas:
        '1.3.10' > '1.3.8'  # False
    """
    try:
        # This hack makes it possible to use 'rc' in the version, where
        # 'rc' must be followed by a single digit.
        ver = version.replace('rc', '.dev99999')
        return NormalizedVersion(ver)
    except IrrationalVersionError:
        # If obtaining the RationalVersion object fails (for example for
        # the version '2009j'), simply return the string, such that
        # a string comparison can be made.
        return version

def md5_file(path):
    """
    Returns the md5sum of the file (located at `path`) as a hexadecimal
    string of length 32.
    """
    fi = open(path, 'rb')
    h = hashlib.new('md5')
    while True:
        chunk = fi.read(65536)
        if not chunk:
            break
        h.update(chunk)
    fi.close()
    return h.hexdigest()

def open_with_auth(url):
    """
    Open a urllib2 request, handling HTTP authentication
    """
    import config

    scheme, netloc, path, params, query, frag = urlparse.urlparse(url)
    assert not query
    auth, host = urllib2.splituser(netloc)
    if auth:
        auth = urllib2.unquote(auth).encode('base64').strip()
    elif 'enthought.com/repo/' in url and 'repo/pypi/eggs/' not in url:
        auth = config.get('EPD_auth')
        if auth is None:
            userpass = config.get('EPD_userpass')
            if userpass:
                auth = userpass.encode('base64').strip()

    if auth:
        new_url = urlparse.urlunparse((scheme, host, path,
                                       params, query, frag))
        request = urllib2.Request(new_url)
        request.add_header("Authorization", "Basic " + auth)
    else:
        request = urllib2.Request(url)
    request.add_header('User-Agent', 'enstaller/%s' % __version__)
    try:
        return urllib2.urlopen(request)
    except urllib2.HTTPError as e:
        if '401' in str(e):
            sys.exit("""%s
Please make sure you are using the correct authentication.
Use "enpkg --userpass" to update authentication in configuration file.""" % e)
        else:
            sys.exit(str(e))

def write_data_from_url(fo, url, md5=None, size=None):
    """
    Read data from the url and write to the file handle fo, which must be
    open for writing.  Optionally check the MD5.  When the size in bytes
    is provided, a progress bar is displayed using the download/copy.
    """
    if size:
        sys.stdout.write('%9s [' % human_bytes(size))
        sys.stdout.flush()
        n = cur = 0

    if url.startswith('file://'):
        path = url[7:]
        fi = open(path, 'rb')
    elif url.startswith(('http://', 'https://')):
        try:
            fi = open_with_auth(url)
        except urllib2.URLError, e:
            sys.exit("%s %s" % (e, url))
    else:
        sys.exit("Error: invalid url: %r" % url)

    h = hashlib.new('md5')

    if size and size < 16384:
        buffsize = 1
    else:
        buffsize = 256

    while True:
        chunk = fi.read(buffsize)
        if not chunk:
            break
        fo.write(chunk)
        if md5:
            h.update(chunk)
        if not size:
            continue
        n += len(chunk)
        if float(n) / size * 64 >= cur:
            sys.stdout.write('.')
            sys.stdout.flush()
            cur += 1

    if size:
        sys.stdout.write(']\n')
        sys.stdout.flush()

    fi.close()

    if md5 and h.hexdigest() != md5:
        sys.stderr.write("FATAL ERROR: Data received from\n\n"
                         "    %s\n\n"
                         "is corrupted.  MD5 sums mismatch.\n" % url)
        fo.close()
        sys.exit(1)

# -----------------------------------------------------------------

repo_pat = re.compile(r'/repo/([^\s/]+/[^\s/]+)/')
def shorten_repo(repo):
    m = repo_pat.search(repo)
    if m:
        return m.group(1)
    else:
        res = repo.replace('http://', '').replace('https://', '')
        return res.replace('.enthought.com', '')

def get_installed_info(prefix, cname):
    """
    return a dictionary with information about the package specified by the
    canonical name found in prefix, or None if the package is not found
    """
    meta_dir = join(prefix, 'EGG-INFO', cname)
    meta_txt = join(meta_dir, '__egginst__.txt')
    if not isfile(meta_txt):
        return None

    d = {}
    execfile(meta_txt, d)
    res = {}
    res['egg_name'] = d['egg_name']
    res['name'], res['version'] = name_version_fn(d['egg_name'])
    res['mtime'] = time.ctime(getmtime(meta_txt))
    res['meta_dir'] = meta_dir

    meta2_txt = join(meta_dir, '__enpkg__.txt')
    if isfile(meta2_txt):
        d = {}
        execfile(meta2_txt, d)
        res['repo'] = shorten_repo(d['repo'])
    return res

def get_info():
    """
    returns a dict mapping canonical project names to spec structures
    containing additional meta-data of the project which is not contained
    in the index-depend data
    """
    from indexed_repo.metadata import parse_index
    import config

    url = config.get('info_url')
    faux = StringIO()
    write_data_from_url(faux, url)
    index_data = faux.getvalue()
    faux.close()

    if url.endswith('.bz2'):
        index_data = bz2.decompress(index_data)

    res = {}
    for name, data in parse_index(index_data).iteritems():
        d = {}
        exec data.replace('\r', '') in d
        cname = canonical(name)
        res[cname] = {}
        for var_name in ('name', 'homepage', 'doclink', 'license',
                         'summary', 'description'):
            res[cname][var_name] = d[var_name]
    return res

def get_available():
    """
    return a dict mapping canonical project names to versions which
    are available in the subscriber repositories
    """
    import plat
    import config

    url = '%savailable/%s.txt' % (config.pypi_url, plat.custom_plat)
    faux = StringIO()
    write_data_from_url(faux, url)
    data = faux.getvalue()
    faux.close()

    res = {}
    for line in data.splitlines():
        line = line.strip()
        if line:
            parts = line.split()
            cname = parts[0]
            versions = parts[1:]
            res[cname] = versions
    return res
<commit_msg>ENH: simplified error handling<commit_after>import bz2
import re
import sys
import time
import hashlib
import urlparse
import urllib2
from cStringIO import StringIO
from os.path import abspath, expanduser, getmtime, isfile, join

from egginst import name_version_fn
from egginst.utils import human_bytes
from enstaller import __version__
from enstaller.verlib import NormalizedVersion, IrrationalVersionError

PY_VER = '%i.%i' % sys.version_info[:2]

def abs_expanduser(path):
    return abspath(expanduser(path))

def canonical(s):
    """
    return the canonical representations of a project name
    """
    # eventually (once Python 2.6 repo eggs are no longer supported), this
    # function should only return s.lower()
    s = s.lower()
    s = s.replace('-', '_')
    if s == 'tables':
        s = 'pytables'
    return s

def cname_fn(fn):
    return canonical(fn.split('-')[0])

def comparable_version(version):
    """
    Given a version string (e.g. '1.3.0.dev234'), return an object which
    allows correct comparison. For example:
        comparable_version('1.3.10') > comparable_version('1.3.8')  # True
    whereas:
        '1.3.10' > '1.3.8'  # False
    """
    try:
        # This hack makes it possible to use 'rc' in the version, where
        # 'rc' must be followed by a single digit.
        ver = version.replace('rc', '.dev99999')
        return NormalizedVersion(ver)
    except IrrationalVersionError:
        # If obtaining the RationalVersion object fails (for example for
        # the version '2009j'), simply return the string, such that
        # a string comparison can be made.
        return version

def md5_file(path):
    """
    Returns the md5sum of the file (located at `path`) as a hexadecimal
    string of length 32.
    """
    fi = open(path, 'rb')
    h = hashlib.new('md5')
    while True:
        chunk = fi.read(65536)
        if not chunk:
            break
        h.update(chunk)
    fi.close()
    return h.hexdigest()

def open_with_auth(url):
    """
    Open a urllib2 request, handling HTTP authentication
    """
    import config

    scheme, netloc, path, params, query, frag = urlparse.urlparse(url)
    assert not query
    auth, host = urllib2.splituser(netloc)
    if auth:
        auth = urllib2.unquote(auth).encode('base64').strip()
    elif 'enthought.com/repo/' in url and 'repo/pypi/eggs/' not in url:
        auth = config.get('EPD_auth')
        if auth is None:
            userpass = config.get('EPD_userpass')
            if userpass:
                auth = userpass.encode('base64').strip()

    if auth:
        new_url = urlparse.urlunparse((scheme, host, path,
                                       params, query, frag))
        request = urllib2.Request(new_url)
        request.add_header("Authorization", "Basic " + auth)
    else:
        request = urllib2.Request(url)
    request.add_header('User-Agent', 'enstaller/%s' % __version__)
    try:
        return urllib2.urlopen(request)
    except urllib2.HTTPError as e:
        sys.stderr.write(str(e) + '\n')
        if '401' in str(e):
            sys.stderr.write("""\
Please make sure you are using the correct authentication.
Use "enpkg --userpass" to update authentication in configuration file.
""")
        sys.exit(1)

def write_data_from_url(fo, url, md5=None, size=None):
    """
    Read data from the url and write to the file handle fo, which must be
    open for writing.  Optionally check the MD5.  When the size in bytes
    is provided, a progress bar is displayed using the download/copy.
    """
    if size:
        sys.stdout.write('%9s [' % human_bytes(size))
        sys.stdout.flush()
        n = cur = 0

    if url.startswith('file://'):
        path = url[7:]
        fi = open(path, 'rb')
    elif url.startswith(('http://', 'https://')):
        try:
            fi = open_with_auth(url)
        except urllib2.URLError, e:
            sys.exit("%s %s" % (e, url))
    else:
        sys.exit("Error: invalid url: %r" % url)

    h = hashlib.new('md5')

    if size and size < 16384:
        buffsize = 1
    else:
        buffsize = 256

    while True:
        chunk = fi.read(buffsize)
        if not chunk:
            break
        fo.write(chunk)
        if md5:
            h.update(chunk)
        if not size:
            continue
        n += len(chunk)
        if float(n) / size * 64 >= cur:
            sys.stdout.write('.')
            sys.stdout.flush()
            cur += 1

    if size:
        sys.stdout.write(']\n')
        sys.stdout.flush()

    fi.close()

    if md5 and h.hexdigest() != md5:
        sys.stderr.write("FATAL ERROR: Data received from\n\n"
                         "    %s\n\n"
                         "is corrupted.  MD5 sums mismatch.\n" % url)
        fo.close()
        sys.exit(1)

# -----------------------------------------------------------------

repo_pat = re.compile(r'/repo/([^\s/]+/[^\s/]+)/')
def shorten_repo(repo):
    m = repo_pat.search(repo)
    if m:
        return m.group(1)
    else:
        res = repo.replace('http://', '').replace('https://', '')
        return res.replace('.enthought.com', '')

def get_installed_info(prefix, cname):
    """
    return a dictionary with information about the package specified by the
    canonical name found in prefix, or None if the package is not found
    """
    meta_dir = join(prefix, 'EGG-INFO', cname)
    meta_txt = join(meta_dir, '__egginst__.txt')
    if not isfile(meta_txt):
        return None

    d = {}
    execfile(meta_txt, d)
    res = {}
    res['egg_name'] = d['egg_name']
    res['name'], res['version'] = name_version_fn(d['egg_name'])
    res['mtime'] = time.ctime(getmtime(meta_txt))
    res['meta_dir'] = meta_dir

    meta2_txt = join(meta_dir, '__enpkg__.txt')
    if isfile(meta2_txt):
        d = {}
        execfile(meta2_txt, d)
        res['repo'] = shorten_repo(d['repo'])
    return res

def get_info():
    """
    returns a dict mapping canonical project names to spec structures
    containing additional meta-data of the project which is not contained
    in the index-depend data
    """
    from indexed_repo.metadata import parse_index
    import config

    url = config.get('info_url')
    faux = StringIO()
    write_data_from_url(faux, url)
    index_data = faux.getvalue()
    faux.close()

    if url.endswith('.bz2'):
        index_data = bz2.decompress(index_data)

    res = {}
    for name, data in parse_index(index_data).iteritems():
        d = {}
        exec data.replace('\r', '') in d
        cname = canonical(name)
        res[cname] = {}
        for var_name in ('name', 'homepage', 'doclink', 'license',
                         'summary', 'description'):
            res[cname][var_name] = d[var_name]
    return res

def get_available():
    """
    return a dict mapping canonical project names to versions which
    are available in the subscriber repositories
    """
    import plat
    import config

    url = '%savailable/%s.txt' % (config.pypi_url, plat.custom_plat)
    faux = StringIO()
    write_data_from_url(faux, url)
    data = faux.getvalue()
    faux.close()

    res = {}
    for line in data.splitlines():
        line = line.strip()
        if line:
            parts = line.split()
            cname = parts[0]
            versions = parts[1:]
            res[cname] = versions
    return res
<|endoftext|>


<commit_before>from talib import ATR
from time import time

def initialize(context):
    """
    Initialize parameters.
    """
    context.is_debug = True

    if context.is_debug:
        start_time = time()

    # Data
    context.symbols = [
        'BP',
        'CD',
        'CL',
        'ED',
        'GC',
        'HG',
        'HO',
        'HU',
        'JY',
        'SB',
        'SF',
        'SP',
        'SV',
        'TB',
        'TY',
        'US'
    ]
    context.markets = None
    context.prices = None
    context.contract = None
    context.contracts = None
    context.open_orders = None
    context.average_true_range = {}
    context.dollar_volatility = {}
    context.trade_size = {}

    # Signal
    context.twenty_day_breakout = 20
    context.fifty_five_day_breakout = 55
    context.twenty_day_high = {}
    context.twenty_day_low = {}
    context.fifty_five_day_high = {}
    context.fifty_five_day_low = {}

    # Risk
    context.price_threshold = 1
    context.capital = context.portfolio.starting_cash
    context.profit = None
    context.capital_risk_per_trade = 0.01
    context.capital_multiplier = 2
    context.stop = {}
    context.has_stop = {}
    context.stop_multiplier = 2
    context.single_market_limit = 4
    context.closely_correlated_market_limit = 6
    context.loosely_correlated_market_limit = 6
    context.long_limit = 12
    context.short_limit = 12

    schedule_function(
        func=validate_markets,
        time_rule=time_rules.market_open(minutes=1)
    )

    schedule_function(
        func=clear_stops,
        time_rule=time_rules.market_open(minutes=1)
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.symbols) == 16)

def handle_data(context, data):
    """
    Process data every minute.
    """
    if context.is_debug:
        start_time = time()

    if context.markets is not None:
        get_prices(context, data)
        validate_prices(context)
        context.prices = context.prices.transpose(2, 1, 0)
        context.prices = context.prices.reindex()
        compute_high(context)
        compute_low(context)
        get_contracts(context, data)
        context.open_orders = get_open_orders()
        compute_average_true_range(context)
        compute_dollar_volatility(context)
        compute_trade_size(context)

        for position in context.portfolio.positions:
            market = continuous_future(position.root_symbol)

            if not context.has_stop[market]:
                order_target(
                    position,
                    0,
                    style=StopOrder(context.stop[market])
                )
                context.has_stop[market] = True

                if context.is_debug:
                    log.debug(
                        'Stop %s %.2f'
                        % (
                            market.root_symbol,
                            context.stop[market]
                        )
                    )

        for market in context.prices.items:
            price = context.prices[market].close[-1]

            if price > context.twenty_day_high[market]\
                    or price > context.fifty_five_day_high[market]:
                if is_trade_allowed(context, market, price):
                    order(
                        context.contract,
                        context.trade_size[market],
                        style=LimitOrder(price)
                    )
                    context.stop[market] = price\
                        - context.average_true_range[market]\
                        * context.stop_multiplier

                    if context.is_debug:
                        log.debug(
                            'Long %s %i@%.2f'
                            % (
                                market.root_symbol,
                                context.trade_size[market],
                                price
                            )
                        )
            if price < context.twenty_day_low[market]\
                    or price < context.fifty_five_day_low[market]:
                if is_trade_allowed(context, market, price):
                    order(
                        context.contract,
                        -context.trade_size[market],
                        style=LimitOrder(price)
                    )
                    context.stop[market] = price\
                        + context.average_true_range[market]\
                        * context.stop_multiplier

                    if context.is_debug:
                        log.debug(
                            'Short %s %i@%.2f'
                            % (
                                market.root_symbol,
                                context.trade_size[market],
                                price
                            )
                        )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 8192)

def validate_markets(context, data):
    """
    Drop markets that stopped trading.
    """
    if context.is_debug:
        start_time = time()

    context.markets = map(
        lambda market: continuous_future(market),
        context.symbols
    )

    markets = context.markets[:]

    for market in markets:
        if market.end_date < get_datetime():
            context.markets.remove(market)

            if context.is_debug:
                log.debug(
                    '%s stopped trading. Dropped.'
                    % market.root_symbol
                )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.markets) == 14)

def clear_stops(context, data):
    """
    Clear stop flags.
    """
    for market in context.markets:
        context.has_stop[market] = False

def get_prices(context, data):
    """
    Get high, low, and close prices.
    """
    if context.is_debug:
        start_time = time()

    fields = ['high', 'low', 'close']
    bars = 22
    frequency = '1d'

    context.prices = data.history(
        context.markets,
        fields,
        bars,
        frequency
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 8192)
        assert(context.prices.shape[0] == 3)
        assert(context.prices.shape[1] == 22)
        assert(context.prices.shape[2] > 8)

def validate_prices(context):
    """
    Drop markets with null prices.
    """
    if context.is_debug:
        start_time = time()

    context.prices.dropna(axis=2, inplace=True)

    validated_markets = map(
        lambda market: market.root_symbol,
        context.prices.axes[2]
    )

    markets = map(
        lambda market: market.root_symbol,
        context.markets
    )

    dropped_markets = list(
        set(markets) - set(validated_markets)
    )

    if context.is_debug and dropped_markets:
        log.debug(
            'Null prices for %s. Dropped.'
            % ', '.join(dropped_markets)
        )

    context.markets = map(
        lambda market: continuous_future(market),
        validated_markets
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(context.prices.shape[0] == 3)
        assert(context.prices.shape[1] == 22)
        assert(context.prices.shape[2] > 8)

def compute_high(context):
    """
    Compute 20 and 55 day high.
    """
    if context.is_debug:
        start_time = time()

    for market in context.prices.items:
        context.twenty_day_high[market] = context\
            .prices[market]\
            .high[-context.twenty_day_breakout-1:-1]\
            .max()
        context.fifty_five_day_high[market] = context\
            .prices[market]\
            .high[-context.fifty_five_day_breakout-1:-1]\
            .max()

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.twenty_day_high) > 8)
        assert(len(context.fifty_five_day_high) > 8)

def compute_low(context):
    """
    Compute 20 and 55 day low.
    """
    if context.is_debug:
        start_time = time()

    for market in context.prices.items:
        context.twenty_day_low[market] = context\
            .prices[market]\
            .low[-context.twenty_day_breakout-1:-1]\
            .min()
        context.fifty_five_day_low[market] = context\
            .prices[market]\
            .low[-context.fifty_five_day_breakout-1:-1]\
            .min()

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.twenty_day_low) > 8)
        assert(len(context.fifty_five_day_low) > 8)

def get_contracts(context, data):
    """
    Get current contracts.
    """
    if context.is_debug:
        start_time = time()

    fields = 'contract'

    context.contracts = data.current(
        context.markets,
        fields
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(context.contracts.shape[0] > 8)

def is_trade_allowed(context, market, price):
    """
    Check if can trade.
    """
    is_trade_allowed = True

    if context.portfolio.cash <= 0:
        is_trade_allowed = False

    if context.capital <= 0:
        is_trade_allowed = False

    if price < context.price_threshold:
        is_trade_allowed = False

    if context.open_orders:
        context.contract = context.contracts[market]

        if context.contract in context.open_orders:
            is_trade_allowed = False

    return is_trade_allowed

def compute_average_true_range(context):
    """
    Compute average true range, or N.
    """
    if context.is_debug:
        start_time = time()

    rolling_window = 21
    moving_average = 20

    for market in context.markets:
        context.average_true_range[market] = ATR(
            context.prices[market].high[-rolling_window:],
            context.prices[market].low[-rolling_window:],
            context.prices[market].close[-rolling_window:],
            timeperiod=moving_average
        )[-1]

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.average_true_range) > 8)

def compute_dollar_volatility(context):
    """
    Compute dollar volatility.
    """
    if context.is_debug:
        start_time = time()

    for market in context.markets:
        context.contract = context.contracts[market]

        context.dollar_volatility[market] = context.contract.multiplier\
            * context.average_true_range[market]

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        print(context.dollar_volatility)
        assert(len(context.dollar_volatility) > 8)

def compute_trade_size(context):
    """
    Compute trade size.
    """
    if context.is_debug:
        start_time = time()

    context.profit = context.portfolio.portfolio_value\
        - context.portfolio.starting_cash

    if context.profit < 0:
        context.capital = context.portfolio.starting_cash\
            + context.profit\
            * context.capital_multiplier

    if context.capital <= 0:
        for market in context.markets:
            context.trade_size[market] = 0
    else:
        for market in context.markets:
            context.trade_size[market] = int(context.capital\
                * context.capital_risk_per_trade\
                / context.dollar_volatility[market])

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.trade_size) >= 8)<commit_msg>Refactor<commit_after>from talib import ATR
from time import time

def initialize(context):
    """
    Initialize parameters.
    """
    context.is_debug = True

    if context.is_debug:
        start_time = time()

    # Data
    context.symbols = [
        'BP',
        'CD',
        'CL',
        'ED',
        'GC',
        'HG',
        'HO',
        'HU',
        'JY',
        'SB',
        'SF',
        'SP',
        'SV',
        'TB',
        'TY',
        'US'
    ]
    context.markets = map(
        lambda market: continuous_future(market),
        context.symbols
    )
    context.prices = None
    context.contract = None
    context.contracts = None
    context.open_orders = None
    context.average_true_range = {}
    context.dollar_volatility = {}
    context.trade_size = {}

    # Signal
    context.twenty_day_breakout = 20
    context.fifty_five_day_breakout = 55
    context.twenty_day_high = {}
    context.twenty_day_low = {}
    context.fifty_five_day_high = {}
    context.fifty_five_day_low = {}

    # Risk
    context.price_threshold = 1
    context.capital = context.portfolio.starting_cash
    context.profit = None
    context.capital_risk_per_trade = 0.01
    context.capital_multiplier = 2
    context.stop = {}
    context.has_stop = {}
    context.stop_multiplier = 2
    context.single_market_limit = 4
    context.closely_correlated_market_limit = 6
    context.loosely_correlated_market_limit = 6
    context.long_limit = 12
    context.short_limit = 12

    schedule_function(
        func=clear_stops,
        time_rule=time_rules.market_open(minutes=1)
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.symbols) == 16)

def handle_data(context, data):
    """
    Process data every minute.
    """
    if context.is_debug:
        start_time = time()

    if context.markets is not None:
        get_prices(context, data)
        validate_prices(context)
        context.prices = context.prices.transpose(2, 1, 0)
        context.prices = context.prices.reindex()
        compute_high(context)
        compute_low(context)
        get_contracts(context, data)
        context.open_orders = get_open_orders()
        compute_average_true_range(context)
        compute_dollar_volatility(context)
        compute_trade_size(context)

        for position in context.portfolio.positions:
            market = continuous_future(position.root_symbol)

            if not context.has_stop[market]:
                order_target(
                    position,
                    0,
                    style=StopOrder(context.stop[market])
                )
                context.has_stop[market] = True

                if context.is_debug:
                    log.debug(
                        'Stop %s %.2f'
                        % (
                            market.root_symbol,
                            context.stop[market]
                        )
                    )

        for market in context.prices.items:
            price = context.prices[market].close[-1]

            if price > context.twenty_day_high[market]\
                    or price > context.fifty_five_day_high[market]:
                if is_trade_allowed(context, market, price):
                    order(
                        context.contract,
                        context.trade_size[market],
                        style=LimitOrder(price)
                    )
                    context.stop[market] = price\
                        - context.average_true_range[market]\
                        * context.stop_multiplier

                    if context.is_debug:
                        log.debug(
                            'Long %s %i@%.2f'
                            % (
                                market.root_symbol,
                                context.trade_size[market],
                                price
                            )
                        )
            if price < context.twenty_day_low[market]\
                    or price < context.fifty_five_day_low[market]:
                if is_trade_allowed(context, market, price):
                    order(
                        context.contract,
                        -context.trade_size[market],
                        style=LimitOrder(price)
                    )
                    context.stop[market] = price\
                        + context.average_true_range[market]\
                        * context.stop_multiplier

                    if context.is_debug:
                        log.debug(
                            'Short %s %i@%.2f'
                            % (
                                market.root_symbol,
                                context.trade_size[market],
                                price
                            )
                        )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 8192)

def clear_stops(context, data):
    """
    Clear stop flags.
    """
    for market in context.markets:
        context.has_stop[market] = False

def get_prices(context, data):
    """
    Get high, low, and close prices.
    """
    if context.is_debug:
        start_time = time()

    fields = ['high', 'low', 'close']
    bars = 22
    frequency = '1d'

    context.prices = data.history(
        context.markets,
        fields,
        bars,
        frequency
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 8192)
        assert(context.prices.shape[0] == 3)
        assert(context.prices.shape[1] == 22)
        assert(context.prices.shape[2] > 8)

def validate_prices(context):
    """
    Drop markets with null prices.
    """
    if context.is_debug:
        start_time = time()

    context.prices.dropna(axis=2, inplace=True)

    validated_markets = map(
        lambda market: market.root_symbol,
        context.prices.axes[2]
    )

    markets = map(
        lambda market: market.root_symbol,
        context.markets
    )

    dropped_markets = list(
        set(markets) - set(validated_markets)
    )

    if context.is_debug and dropped_markets:
        log.debug(
            'Null prices for %s. Dropped.'
            % ', '.join(dropped_markets)
        )

    context.markets = map(
        lambda market: continuous_future(market),
        validated_markets
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(context.prices.shape[0] == 3)
        assert(context.prices.shape[1] == 22)
        assert(context.prices.shape[2] > 8)

def compute_high(context):
    """
    Compute 20 and 55 day high.
    """
    if context.is_debug:
        start_time = time()

    for market in context.prices.items:
        context.twenty_day_high[market] = context\
            .prices[market]\
            .high[-context.twenty_day_breakout-1:-1]\
            .max()
        context.fifty_five_day_high[market] = context\
            .prices[market]\
            .high[-context.fifty_five_day_breakout-1:-1]\
            .max()

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.twenty_day_high) > 8)
        assert(len(context.fifty_five_day_high) > 8)

def compute_low(context):
    """
    Compute 20 and 55 day low.
    """
    if context.is_debug:
        start_time = time()

    for market in context.prices.items:
        context.twenty_day_low[market] = context\
            .prices[market]\
            .low[-context.twenty_day_breakout-1:-1]\
            .min()
        context.fifty_five_day_low[market] = context\
            .prices[market]\
            .low[-context.fifty_five_day_breakout-1:-1]\
            .min()

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.twenty_day_low) > 8)
        assert(len(context.fifty_five_day_low) > 8)

def get_contracts(context, data):
    """
    Get current contracts.
    """
    if context.is_debug:
        start_time = time()

    fields = 'contract'

    context.contracts = data.current(
        context.markets,
        fields
    )

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(context.contracts.shape[0] > 8)

def is_trade_allowed(context, market, price):
    """
    Check if can trade.
    """
    is_trade_allowed = True

    if context.portfolio.cash <= 0:
        is_trade_allowed = False

    if context.capital <= 0:
        is_trade_allowed = False

    if price < context.price_threshold:
        is_trade_allowed = False

    if context.open_orders:
        context.contract = context.contracts[market]

        if context.contract in context.open_orders:
            is_trade_allowed = False

    return is_trade_allowed

def compute_average_true_range(context):
    """
    Compute average true range, or N.
    """
    if context.is_debug:
        start_time = time()

    rolling_window = 21
    moving_average = 20

    for market in context.markets:
        context.average_true_range[market] = ATR(
            context.prices[market].high[-rolling_window:],
            context.prices[market].low[-rolling_window:],
            context.prices[market].close[-rolling_window:],
            timeperiod=moving_average
        )[-1]

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.average_true_range) > 8)

def compute_dollar_volatility(context):
    """
    Compute dollar volatility.
    """
    if context.is_debug:
        start_time = time()

    for market in context.markets:
        context.contract = context.contracts[market]

        context.dollar_volatility[market] = context.contract.multiplier\
            * context.average_true_range[market]

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        print(context.dollar_volatility)
        assert(len(context.dollar_volatility) > 8)

def compute_trade_size(context):
    """
    Compute trade size.
    """
    if context.is_debug:
        start_time = time()

    context.profit = context.portfolio.portfolio_value\
        - context.portfolio.starting_cash

    if context.profit < 0:
        context.capital = context.portfolio.starting_cash\
            + context.profit\
            * context.capital_multiplier

    if context.capital <= 0:
        for market in context.markets:
            context.trade_size[market] = 0
    else:
        for market in context.markets:
            context.trade_size[market] = int(context.capital\
                * context.capital_risk_per_trade\
                / context.dollar_volatility[market])

    if context.is_debug:
        time_taken = (time() - start_time) * 1000
        # log.debug('Executed in %f ms.' % time_taken)
        assert(time_taken < 1024)
        assert(len(context.trade_size) >= 8)<|endoftext|>


<commit_before># Copyright (c) 2014 Stefan C. Mueller

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

from setuptools import setup
import os.path

if os.path.exists('README.rst'):
    with open('README.rst') as f:
        long_description = f.read()
else:
    long_description = ""

setup(name='twistit',
      version='0.1.0',
      description='Handy tools for the twisted framework',
      long_description=long_description,
      author='Stefan C. Mueller',
      author_email='scm@smurn.org',
      url='https://github.com/smurn/twistit',
      packages=['twistit'],
     )
<commit_msg>Added dependency to twisted.<commit_after># Copyright (c) 2014 Stefan C. Mueller

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

from setuptools import setup
import os.path

if os.path.exists('README.rst'):
    with open('README.rst') as f:
        long_description = f.read()
else:
    long_description = ""

setup(name='twistit',
      version='0.1.0',
      description='Handy tools for the twisted framework',
      long_description=long_description,
      author='Stefan C. Mueller',
      author_email='scm@smurn.org',
      url='https://github.com/smurn/twistit',
      packages=['twistit'],
      install_requires = ['Twisted'],
     )
<|endoftext|>


<commit_before># ===============================================================================
# Copyright 2017 dgketchum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

import os

os.environ['TRAVIS_CI'] = 'True'

try:
    from setuptools import setup

    # setup_kwargs = {'entry_points': {'console_scripts': ['sat_image=sat_image.landsat_cli:cli_runner']}}
except ImportError:

    from distutils.core import setup

    # setup_kwargs = {'scripts': ['bin/sat_image/landsat_cli']}

with open('README.md') as f:
    readme = f.read()

tag = '0.1.27'
name = 'SatelliteImage'

setup(name=name,
      version=tag,
      description='Simple API provides a class to process satellite images',
      setup_requires=['nose>=1.0'],
      license='Apache',
      classifiers=[
          'Development Status :: 3 - Alpha',
          'Intended Audience :: Science/Research',
          'Topic :: Scientific/Engineering :: GIS',
          'License :: OSI Approved :: Apache Software License',
          'Programming Language :: Python :: 2.7',
          'Programming Language :: Python :: 3.6'],
      keywords='landsat download hydrology remote sensing',
      author='David Ketchum',
      author_email='dgketchum@gmail.com',
      platforms='Posix; MacOS X; Windows',
      packages=['sat_image'],
      download_url='https://github.com/{}/{}/archive/{}.tar.gz'.format('dgketchum',
                                                                       'satellite_image',
                                                                       tag),
      url='https://github.com/dgketchum/satellite_image',
      test_suite='tests.test_suite.suite',
      install_requires=['numpy', 'rasterio==1.0a12', 'shapely', 'fiona', 'pyproj', 'scipy'])
# **setup_kwargs)

# ============= EOF ===========================================================================
<commit_msg>tag 0.1.28<commit_after># ===============================================================================
# Copyright 2017 dgketchum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

import os

os.environ['TRAVIS_CI'] = 'True'

try:
    from setuptools import setup

    # setup_kwargs = {'entry_points': {'console_scripts': ['sat_image=sat_image.landsat_cli:cli_runner']}}
except ImportError:

    from distutils.core import setup

    # setup_kwargs = {'scripts': ['bin/sat_image/landsat_cli']}

with open('README.md') as f:
    readme = f.read()

tag = '0.1.28'
name = 'SatelliteImage'

setup(name=name,
      version=tag,
      description='Simple API provides a class to process satellite images',
      setup_requires=['nose>=1.0'],
      license='Apache',
      classifiers=[
          'Development Status :: 3 - Alpha',
          'Intended Audience :: Science/Research',
          'Topic :: Scientific/Engineering :: GIS',
          'License :: OSI Approved :: Apache Software License',
          'Programming Language :: Python :: 2.7',
          'Programming Language :: Python :: 3.6'],
      keywords='landsat download hydrology remote sensing',
      author='David Ketchum',
      author_email='dgketchum@gmail.com',
      platforms='Posix; MacOS X; Windows',
      packages=['sat_image'],
      download_url='https://github.com/{}/{}/archive/{}.tar.gz'.format('dgketchum',
                                                                       'satellite_image',
                                                                       tag),
      url='https://github.com/dgketchum/satellite_image',
      test_suite='tests.test_suite.suite',
      install_requires=['numpy', 'rasterio==1.0a12', 'shapely', 'fiona', 'pyproj', 'scipy'])
# **setup_kwargs)

# ============= EOF ===========================================================================
<|endoftext|>


<commit_before>import os
from distutils.core import setup

version = '0.9.3'

def read_file(name):
    return open(os.path.join(os.path.dirname(__file__),
                             name)).read()

readme = read_file('README.rst')
changes = read_file('CHANGES')

setup(
    name='django-maintenancemode',
    version=version,
    description='Django-maintenancemode allows you to temporary shutdown your site for maintenance work',
    long_description='\n\n'.join([readme, changes]),
    author='Remco Wendt',
    author_email='remco@maykinmedia.nl',
    license = "BSD",
    platforms = ["any"],
    url='https://github.com/shanx/django-maintenancemode',
    download_url='',
    packages=[
        'maintenancemode',
        'maintenancemode.conf',
        'maintenancemode.conf.settings',
        'maintenancemode.conf.urls',
        'maintenancemode.tests',
        'maintenancemode.views',
    ],
    include_package_data = False,
    classifiers=[
            'Development Status :: 4 - Beta',
            'Environment :: Web Environment',
            'Framework :: Django',
            'Intended Audience :: Developers',
            'License :: OSI Approved :: BSD License',
            'Operating System :: OS Independent',
            'Programming Language :: Python',
            'Topic :: Utilities',
    ],
)
<commit_msg>Added package_data parameter to setup() call to fix packaging of the test template.<commit_after>import os
from distutils.core import setup

version = '0.9.3'

def read_file(name):
    return open(os.path.join(os.path.dirname(__file__),
                             name)).read()

readme = read_file('README.rst')
changes = read_file('CHANGES')

setup(
    name='django-maintenancemode',
    version=version,
    description='Django-maintenancemode allows you to temporary shutdown your site for maintenance work',
    long_description='\n\n'.join([readme, changes]),
    author='Remco Wendt',
    author_email='remco@maykinmedia.nl',
    license="BSD",
    platforms=["any"],
    url='https://github.com/shanx/django-maintenancemode',
    packages=[
        'maintenancemode',
        'maintenancemode.conf',
        'maintenancemode.conf.settings',
        'maintenancemode.conf.urls',
        'maintenancemode.tests',
        'maintenancemode.views',
    ],
    package_data={
        'maintenancemode': [
            'tests/templates/503.html',
        ],
    },
    classifiers=[
            'Development Status :: 4 - Beta',
            'Environment :: Web Environment',
            'Framework :: Django',
            'Intended Audience :: Developers',
            'License :: OSI Approved :: BSD License',
            'Operating System :: OS Independent',
            'Programming Language :: Python',
            'Topic :: Utilities',
    ],
)
<|endoftext|>


<commit_before>#!/usr/bin/env python

from setuptools import setup, find_packages

setup(name = 'dreamBeam',
      version = '0.4',
      description = 'Measurement equation framework for interferometry in Radio Astronomy.',
      author = 'Tobia D. Carozzi',
      author_email = 'tobia.carozzi@chalmers.se',
      packages = find_packages(),
      package_data = {'dreambeam.telescopes.LOFAR':
                ['share/*.cc','share/simmos/*.cfg','share/alignment/*.txt','data/*teldat.p']},
      license = 'ISC',
      classifiers = [
          'Development Status :: 1 - Planning',
          'Intended Audience :: Science/Research',
          'License :: OSI Approved :: ISC License',
          'Programming Language :: Python :: 2.7',
          'Topic :: Scientific/Engineering :: Astronomy',
          'Topic :: Scientific/Engineering :: Mathematics',
          'Topic :: Scientific/Engineering :: Visualization'
      ],
      install_requires=[
          'numpy>=1.10',
          'python-casacore',
          'matplotlib',
          'antpat'
      ],
      scripts = ['scripts/pointing_jones.py']
     )
<commit_msg>Change to import version from package.<commit_after>#!/usr/bin/env python

from setuptools import setup, find_packages
from dreambeam import __version__

setup(name='dreamBeam',
      version=__version__,
      description='Measurement equation framework for radio interferometry.',
      author='Tobia D. Carozzi',
      author_email='tobia.carozzi@chalmers.se',
      packages=find_packages(),
      package_data={'dreambeam.telescopes.LOFAR':
                    ['share/*.cc', 'share/simmos/*.cfg',
                     'share/alignment/*.txt', 'data/*teldat.p']},
      license='ISC',
      classifiers=[
          'Development Status :: 1 - Planning',
          'Intended Audience :: Science/Research',
          'License :: OSI Approved :: ISC License',
          'Programming Language :: Python :: 2.7',
          'Topic :: Scientific/Engineering :: Astronomy',
          'Topic :: Scientific/Engineering :: Mathematics',
          'Topic :: Scientific/Engineering :: Visualization'
      ],
      install_requires=[
          'numpy>=1.10',
          'python-casacore',
          'matplotlib',
          'antpat'
      ],
      entry_points={
        'console_scripts': ['pointing_jones = scripts.pointing_jones:cli_main']
      }
      )
<|endoftext|>


<commit_before>__version__ = '1.7.0'  # also in setup.py

from .client import Twarc
from .command import main
<commit_msg>update version in __init__.py<commit_after>__version__ = '1.7.2'  # also in setup.py

from .client import Twarc
from .command import main
<|endoftext|>


<commit_before># flake8: noqa
from .config import EntityConfig, entity_registry, register_entity
from .version import __version__
from .signal_handlers import turn_on_syncing, turn_off_syncing
from .sync import sync_entities

default_app_config = 'entity.apps.EntityConfig'
<commit_msg>do not import files that import models in init<commit_after># flake8: noqa
from .version import __version__

default_app_config = 'entity.apps.EntityConfig'
<|endoftext|>


<commit_before>from distutils.core import setup

_readme = open('README', 'r')
README_TEXT = _readme.read()
_readme.close()

setup(name = 'pytest-incremental',
      description = 'an incremental test runner (pytest plugin)',
      version = '0.1.0',
      license = 'MIT',
      author = 'Eduardo Naufel Schettino',
      author_email = 'schettino72@gmail.com',
      url = 'https://bitbucket.org/schettino72/pytest-incremental',
      classifiers = ['Development Status :: 3 - Alpha',
                     'Environment :: Console',
                     'Intended Audience :: Developers',
                     'License :: OSI Approved :: MIT License',
                     'Natural Language :: English',
                     'Operating System :: OS Independent',
                     'Operating System :: POSIX',
                     'Programming Language :: Python :: 2',
                     'Programming Language :: Python :: 2.6',
                     'Programming Language :: Python :: 2.7',
                     'Topic :: Software Development :: Testing',
                     ],
      py_modules = ['pytest_incremental'],
      install_requires = ['doit', 'pytest', 'pytest-xdist'],
      entry_points = {
        'pytest11': ['pytest_incremental = pytest_incremental'],
        },
      long_description = README_TEXT,
      )

<commit_msg>bump version number on setup.py<commit_after>from distutils.core import setup

_readme = open('README', 'r')
README_TEXT = _readme.read()
_readme.close()

setup(name = 'pytest-incremental',
      description = 'an incremental test runner (pytest plugin)',
      version = '0.2.0',
      license = 'MIT',
      author = 'Eduardo Naufel Schettino',
      author_email = 'schettino72@gmail.com',
      url = 'https://bitbucket.org/schettino72/pytest-incremental',
      classifiers = ['Development Status :: 3 - Alpha',
                     'Environment :: Console',
                     'Intended Audience :: Developers',
                     'License :: OSI Approved :: MIT License',
                     'Natural Language :: English',
                     'Operating System :: OS Independent',
                     'Operating System :: POSIX',
                     'Programming Language :: Python :: 2',
                     'Programming Language :: Python :: 2.6',
                     'Programming Language :: Python :: 2.7',
                     'Topic :: Software Development :: Testing',
                     ],
      py_modules = ['pytest_incremental'],
      install_requires = ['doit', 'pytest', 'pytest-xdist'],
      entry_points = {
        'pytest11': ['pytest_incremental = pytest_incremental'],
        },
      long_description = README_TEXT,
      )

<|endoftext|>