text:
package org.jkiss.dbeaver.registry.driver;

import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.connection.DBPAuthInfo;
import org.jkiss.dbeaver.model.connection.DBPDriverLibrary;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.registry.maven.*;
import org.jkiss.utils.CommonUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * DriverLibraryDescriptor
 */
public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
{
    private static final Log log = Log.getLog(DriverLibraryMavenArtifact.class);

    public static final String PATH_PREFIX = "maven:/";

    private MavenArtifactReference reference;
    protected MavenArtifactVersion localVersion;
    private String preferredVersion;
    private boolean ignoreDependencies;
    private boolean loadOptionalDependencies;
    private final String originalPreferredVersion;

    public DriverLibraryMavenArtifact(DriverDescriptor driver, FileType type, String path, String preferredVersion) {
        super(driver, type, path);
        initArtifactReference(preferredVersion);
        this.originalPreferredVersion = this.preferredVersion;
    }

    public DriverLibraryMavenArtifact(DriverDescriptor driver, IConfigurationElement config) {
        super(driver, config);
        ignoreDependencies = CommonUtils.toBoolean(config.getAttribute("ignore-dependencies"));
        loadOptionalDependencies = CommonUtils.toBoolean(config.getAttribute("load-optional-dependencies"));
        initArtifactReference(null);
        this.originalPreferredVersion = this.preferredVersion;
    }

    private DriverLibraryMavenArtifact(DriverDescriptor driver, DriverLibraryMavenArtifact copyFrom) {
        super(driver, copyFrom);
        this.reference = copyFrom.reference;
        this.localVersion = copyFrom.localVersion;
        this.preferredVersion = copyFrom.preferredVersion;
        this.ignoreDependencies = copyFrom.ignoreDependencies;
        this.loadOptionalDependencies = copyFrom.loadOptionalDependencies;

        this.originalPreferredVersion = copyFrom.originalPreferredVersion;
    }

    public MavenArtifactReference getReference() {
        return reference;
    }

    public void setReference(MavenArtifactReference reference) {
        this.reference = reference;
        this.path = PATH_PREFIX + reference.toString();
        this.localVersion = null;
    }

    private void initArtifactReference(String preferredVersion) {
        if (path.endsWith("]")) {
            int divPos = path.lastIndexOf('[');
            if (divPos != -1) {
                String version = path.substring(divPos + 1, path.length() - 1);
                path = path.substring(0, divPos);
                if (preferredVersion == null) {
                    preferredVersion = version;
                }
            }
        }
        this.reference = new MavenArtifactReference(path);
        if (loadOptionalDependencies) {
            this.reference.setResolveOptionalDependencies(true);
        }

        this.preferredVersion = preferredVersion;
    }

    @Override
    public String getDescription()
    {
        if (localVersion != null) {
            return localVersion.getDescription();
        }
        return null;
    }

    @Override
    public boolean isDownloadable()
    {
        if (localVersion != null) {
            //return !"pom".equals(localVersion.getPackaging());
        }
        return true;
    }

    public boolean isIgnoreDependencies() {
        return ignoreDependencies;
    }

    public void setIgnoreDependencies(boolean ignoreDependencies) {
        this.ignoreDependencies = ignoreDependencies;
    }

    public boolean isLoadOptionalDependencies() {
        return loadOptionalDependencies;
    }

    public void setLoadOptionalDependencies(boolean loadOptionalDependencies) {
        this.loadOptionalDependencies = loadOptionalDependencies;
    }

    @NotNull
    @Override
    public Collection<String> getAvailableVersions(DBRProgressMonitor monitor) throws IOException {
        MavenArtifactVersion artifactVersion = getArtifactVersion(monitor);
        if (artifactVersion != null) {
            Collection<String> availableVersions = artifactVersion.getArtifact().getAvailableVersions(monitor, reference.getVersion());
            if (availableVersions != null) {
                return availableVersions;
            }
        }
        return Collections.emptyList();
    }

    @Override
    public String getPreferredVersion() {
        return preferredVersion;
    }

    @Override
    public void setPreferredVersion(String version) {
        this.preferredVersion = version;
        this.localVersion = null;
    }

    @Override
    public void resetVersion() {
        this.localVersion = null;
        this.preferredVersion = originalPreferredVersion;
        MavenRegistry.getInstance().resetArtifactInfo(reference);
    }

    @Override
    public boolean isSecureDownload(DBRProgressMonitor monitor) {
        try {
            MavenArtifactVersion localVersion = resolveLocalVersion(monitor, false);
            if (localVersion == null) {
                return true;
            }
            return localVersion.getArtifact().getRepository().isSecureRepository();
        } catch (IOException e) {
            log.warn("Error resolving artifact version", e);
            return true;
        }
    }

    @Nullable
    protected MavenArtifactVersion getArtifactVersion(DBRProgressMonitor monitor) {
        if (this.localVersion == null) {
            MavenArtifactReference ref = reference;
            if (preferredVersion != null) {
                ref = new MavenArtifactReference(reference.getGroupId(), reference.getArtifactId(), reference.getFallbackVersion(), preferredVersion);
                if (loadOptionalDependencies) {
                    ref.setResolveOptionalDependencies(true);
                }
            }
            this.localVersion = MavenRegistry.getInstance().findArtifact(monitor, null, ref);
        }
        return this.localVersion;
    }

    @Nullable
    @Override
    public String getExternalURL(DBRProgressMonitor monitor) {
        MavenArtifactVersion localVersion = getArtifactVersion(monitor);
        if (localVersion != null) {
            return localVersion.getExternalURL();
        }
        return null;
    }

    @Nullable
    @Override
    public Path getLocalFile()
    {
        // Try to get local file
        File platformFile = detectLocalFile();
        if (platformFile != null) {
            // Relative file do not exists - use plain one
            return platformFile.toPath();
        }
        // Nothing fits - just return plain url
        return null;
    }

    private File detectLocalFile()
    {
        if (localVersion != null) {
            return localVersion.getCacheFile();
        }
        return null;
    }

    @Nullable
    @Override
    public Collection<? extends DBPDriverLibrary> getDependencies(@NotNull DBRProgressMonitor monitor) throws IOException {
        List<DriverLibraryMavenDependency> dependencies = new ArrayList<>();
        if (ignoreDependencies) {
            return dependencies;
        }
        MavenArtifactVersion localVersion = resolveLocalVersion(monitor, false);
        if (localVersion != null) {

            List<MavenArtifactDependency> artifactDeps = localVersion.getDependencies();
            if (!CommonUtils.isEmpty(artifactDeps)) {
                for (MavenArtifactDependency dependency : artifactDeps) {
                    if (isDependencyExcluded(monitor, dependency)) {
                        continue;
                    }

                    MavenArtifactVersion depArtifact = MavenRegistry.getInstance().findArtifact(monitor, localVersion, dependency);
                    if (depArtifact != null) {
                        dependencies.add(
                            new DriverLibraryMavenDependency(
                                this,
                                depArtifact,
                                dependency));
                    } else {
                        dependency.setBroken(true);
                    }
                }
            }
        }

        return dependencies;
    }

    protected boolean isDependencyExcluded(DBRProgressMonitor monitor, MavenArtifactDependency dependency) {
        return false;
    }

    @NotNull
    public String getDisplayName() {
        return reference.toString();
    }

    @Override
    public String getId() {
        return reference.getId();
    }

    @Override
    public String getVersion() {
        if (preferredVersion != null && !preferredVersion.isEmpty()) {
            return preferredVersion;
        }
        if (localVersion != null) {
            return localVersion.getVersion();
        }

        return reference.getVersion();
    }

    @NotNull
    @Override
    public DBIcon getIcon() {
        return DBIcon.APACHE;
    }

    public void downloadLibraryFile(@NotNull DBRProgressMonitor monitor, boolean forceUpdate, String taskName) throws IOException, InterruptedException {
        //monitor.beginTask(taskName + " - update localVersion information", 1);
        try {
            MavenArtifactVersion localVersion = resolveLocalVersion(monitor, forceUpdate);
            if (localVersion.getArtifact().getRepository().getType() == MavenRepository.RepositoryType.LOCAL) {
                // No need to download local artifacts
                return;
            }
        } finally {
            //monitor.done();
        }
        super.downloadLibraryFile(monitor, forceUpdate, taskName);
    }

    @Nullable
    @Override
    protected DBPAuthInfo getAuthInfo(DBRProgressMonitor monitor) {
        MavenArtifactVersion localVersion = getArtifactVersion(monitor);
        if (localVersion != null) {
            return localVersion.getArtifact().getRepository().getAuthInfo();
        }
        return null;
    }

    @Override
    public DBPDriverLibrary copyLibrary(DriverDescriptor driverDescriptor) {
        return new DriverLibraryMavenArtifact(driver, this);
    }

    protected MavenArtifactVersion resolveLocalVersion(DBRProgressMonitor monitor, boolean forceUpdate) throws IOException {
        if (forceUpdate) {
            MavenRegistry.getInstance().resetArtifactInfo(reference);
        }
        MavenArtifactVersion version = getArtifactVersion(monitor);
        if (version == null) {
            throw new IOException("Maven artifact '" + path + "' not found");
        }
        return version;
    }

}


text:
package com.wordpress.mteixeira.warrantychecker.dell;

/**
 * Created by mteixeir on 7/19/13.
 */
public class Response {
    public DellAsset DellAsset;

    public void setDellAsset(DellAsset dellAsset) {
        this.DellAsset = dellAsset;
    }
    public DellAsset getDellAsset() {
        return DellAsset;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package contactus.view.message;

import contactus.model.Message;
import javafx.scene.control.ListCell;

import java.time.format.DateTimeFormatter;
import java.util.StringJoiner;

public class MessageListCell extends ListCell<Message>{
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;//ofLocalizedDateTime(FormatStyle.MEDIUM);
    private static final String DEFAULT_STYLE_CLASS = "message-list-cell";
    private static final String UNREAD_STYLE_CLASS = "unread";

    public MessageListCell() {
        getStyleClass().add(DEFAULT_STYLE_CLASS);
    }

    @Override
    protected void updateItem(Message item, boolean empty) {
        super.updateItem(item, empty);

        String text = null;
        boolean isUnread = false;

        if (item != null && !empty) {
            text = new StringJoiner(" ")
                    .add(item.getDirection().name())
                    .add(FORMATTER.format(item.getDate()))
                    .add("\n\t")
                    .add(item.getBody())
                    .toString();

            boolean unread = item.isUnread();
            boolean incoming = item.getDirection() == Message.Direction.INPUT;
            isUnread = unread && incoming;
        }

        setText(text);
        if (isUnread && !getStyleClass().contains(UNREAD_STYLE_CLASS)) {
            getStyleClass().add(UNREAD_STYLE_CLASS);
        } else if (!isUnread && getStyleClass().contains(UNREAD_STYLE_CLASS)) {
            getStyleClass().remove(UNREAD_STYLE_CLASS);
        }
    }
}


text:
var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
var ExtensionViewConstants =
    require('extensionViewConstants').ExtensionViewConstants;
var ExtensionViewEvents = require('extensionViewEvents').ExtensionViewEvents;
var ExtensionViewInternal =
    require('extensionViewInternal').ExtensionViewInternal;

function ExtensionViewImpl(extensionviewElement) {
  GuestViewContainer.call(this, extensionviewElement, 'extensionview');

  new ExtensionViewEvents(this, this.viewInstanceId);
}

ExtensionViewImpl.prototype.__proto__ = GuestViewContainer.prototype;

ExtensionViewImpl.VIEW_TYPE = 'ExtensionView';

ExtensionViewImpl.setupElement = function(proto) {
  var apiMethods = ExtensionViewImpl.getApiMethods();

  GuestViewContainer.forwardApiMethods(proto, apiMethods);
};

ExtensionViewImpl.prototype.createGuest = function() {
  this.guest.create(this.buildParams(), function() {
    this.attachWindow();
  }.bind(this));
};

ExtensionViewImpl.prototype.buildContainerParams = function() {
  var params = {};
  for (var i in this.attributes) {
    params[i] = this.attributes[i].getValue();
  }
  return params;
};

ExtensionViewImpl.prototype.onElementDetached = function() {
  this.guest.destroy();

  // Reset all attributes.
  for (var i in this.attributes) {
    this.attributes[i].setValueIgnoreMutation();
  }
};

// Updates src upon loadcommit.
ExtensionViewImpl.prototype.onLoadCommit = function(url) {
  this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC].
      setValueIgnoreMutation(url);
};

GuestViewContainer.registerElement(ExtensionViewImpl);

// Exports.
exports.ExtensionViewImpl = ExtensionViewImpl;


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Z. Mykol. 66(1): 69 (2000)

#### Original name
Dasyscyphus splendens J. Schröt.

### Remarks
null


text:
package org.snaker.engine.access.transaction;

import javax.transaction.Status;
import javax.transaction.Transaction;
import javax.transaction.UserTransaction;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.snaker.engine.SnakerException;

/**
 * JTA事务拦截器
 * @author yuqs
 * @since 1.0
 */
public class JtaTransactionInterceptor extends TransactionInterceptor {
	private static final Logger log = LoggerFactory.getLogger(JtaTransactionInterceptor.class);

	public void initialize(Object accessObject) {
		//ignore
	}

	protected TransactionStatus getTransaction() {
		UserTransaction userTransaction = JtaTransactionHelper
				.lookupJeeUserTransaction();
		int status = JtaTransactionHelper
				.getUserTransactionStatus(userTransaction);
    	if(log.isInfoEnabled()) {
    		log.info("begin transaction=" + status);
    	}
		if (status == Status.STATUS_ACTIVE) {
			return new TransactionStatus(null, false);
		}

		if ((status != Status.STATUS_NO_TRANSACTION)
				&& (status != Status.STATUS_COMMITTED)
				&& (status != Status.STATUS_ROLLEDBACK)) {
			throw new SnakerException("无效的事务状态:" + status);
		}

		Transaction suspendedTransaction = null;
		if ((status == Status.STATUS_ACTIVE)
				|| (status == Status.STATUS_COMMITTED)
				|| (status == Status.STATUS_ROLLEDBACK)) {
			suspendedTransaction = JtaTransactionHelper.suspend();
		}

		try {
			JtaTransactionHelper.begin();
			return new TransactionStatus(null, true);
		} catch (RuntimeException e) {
			throw e;
		} finally {
			if (suspendedTransaction != null) {
				JtaTransactionHelper.resume(suspendedTransaction);
			}
		}
	}

	protected void commit(TransactionStatus status) {
    	if(log.isInfoEnabled()) {
    		log.info("commit transaction=");
    	}
		JtaTransactionHelper.commit();
	}

	protected void rollback(TransactionStatus status) {
		UserTransaction userTransaction = JtaTransactionHelper
				.lookupJeeUserTransaction();
		int txStatus = JtaTransactionHelper
				.getUserTransactionStatus(userTransaction);
    	if(log.isInfoEnabled()) {
    		log.info("rollback transaction=" + txStatus);
    	}
		if ((txStatus != Status.STATUS_NO_TRANSACTION)
				&& (txStatus != Status.STATUS_COMMITTED)
				&& (txStatus != Status.STATUS_ROLLEDBACK)) {
			JtaTransactionHelper.rollback();
		}
	}
}


text:
package de.danoeh.antennapod.core.syndication.namespace;

import android.text.TextUtils;
import android.util.Log;

import org.xml.sax.Attributes;

import java.util.concurrent.TimeUnit;

import de.danoeh.antennapod.core.feed.FeedImage;
import de.danoeh.antennapod.core.syndication.handler.HandlerState;

public class NSITunes extends Namespace {

    public static final String NSTAG = "itunes";
    public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd";

    private static final String IMAGE = "image";
    private static final String IMAGE_TITLE = "image";
    private static final String IMAGE_HREF = "href";

    private static final String AUTHOR = "author";
    public static final String DURATION = "duration";
    public static final String SUBTITLE = "subtitle";
    public static final String SUMMARY = "summary";

    @Override
    public SyndElement handleElementStart(String localName, HandlerState state,
                                          Attributes attributes) {
        if (IMAGE.equals(localName)) {
            FeedImage image = new FeedImage();
            image.setTitle(IMAGE_TITLE);
            image.setDownload_url(attributes.getValue(IMAGE_HREF));

            if (state.getCurrentItem() != null) {
                // this is an items image
                image.setTitle(state.getCurrentItem().getTitle() + IMAGE_TITLE);
                image.setOwner(state.getCurrentItem());
                state.getCurrentItem().setImage(image);
            } else {
                // this is the feed image
                // prefer to all other images
                if (!TextUtils.isEmpty(image.getDownload_url())) {
                    image.setOwner(state.getFeed());
                    state.getFeed().setImage(image);
                }
            }
        }
        return new SyndElement(localName, this);
    }

    @Override
    public void handleElementEnd(String localName, HandlerState state) {
        if(state.getContentBuf() == null) {
            return;
        }
        if (AUTHOR.equals(localName)) {
            if (state.getFeed() != null) {
                String author = state.getContentBuf().toString();
                state.getFeed().setAuthor(author);
            }
        } else if (DURATION.equals(localName)) {
            String durationStr = state.getContentBuf().toString();
            if(TextUtils.isEmpty(durationStr)) {
                return;
            }
            String[] parts = durationStr.trim().split(":");
            try {
                int durationMs = 0;
                if (parts.length == 2) {
                    durationMs += TimeUnit.MINUTES.toMillis(Long.parseLong(parts[0])) +
                            TimeUnit.SECONDS.toMillis((long)Float.parseFloat(parts[1]));
                } else if (parts.length >= 3) {
                    durationMs += TimeUnit.HOURS.toMillis(Long.parseLong(parts[0])) +
                            TimeUnit.MINUTES.toMillis(Long.parseLong(parts[1])) +
                            TimeUnit.SECONDS.toMillis((long)Float.parseFloat(parts[2]));
                } else {
                    return;
                }
                state.getTempObjects().put(DURATION, durationMs);
            } catch (NumberFormatException e) {
                Log.e(NSTAG, "Duration \"" + durationStr + "\" could not be parsed");
            }
        } else if (SUBTITLE.equals(localName)) {
            String subtitle = state.getContentBuf().toString();
            if (TextUtils.isEmpty(subtitle)) {
                return;
            }
            if (state.getCurrentItem() != null) {
                if (TextUtils.isEmpty(state.getCurrentItem().getDescription())) {
                    state.getCurrentItem().setDescription(subtitle);
                }
            } else {
                if (state.getFeed() != null && TextUtils.isEmpty(state.getFeed().getDescription())) {
                    state.getFeed().setDescription(subtitle);
                }
            }
        } else if (SUMMARY.equals(localName)) {
            String summary = state.getContentBuf().toString();
            if (TextUtils.isEmpty(summary)) {
                return;
            }
            if (state.getCurrentItem() != null) {
                state.getCurrentItem().setDescription(summary);
            } else if (state.getFeed() != null) {
                state.getFeed().setDescription(summary);
            }
        }
    }
}


text:
'use strict';
const angular = require('angular');

const uiRouter = require('angular-ui-router');

import routes from './adminPickupOptions.routes';
import {ModalBase} from '../shared/modal.base';

export class AdminPickupOptionsComponent extends ModalBase{
  $http: ng.IHttpService;
  $uibModal: ng.ui.bootstrap.IModalService;
  pickupOptions: Object[] = [];
  PickupOptionsService: Object;

  /*@ngInject*/
  constructor($http, $uibModal, PickupOptionsService) {
    super($uibModal);
    this.$http = $http;
    this.PickupOptionsService = PickupOptionsService;
    this.reload();
  }

  getResolve(pickupOption) {
    return {
      pickupOption: function () {
        return pickupOption;
      }
    };
  }

  delete(pickupOption) {
    let scope = this;
    this.modal('adminPickupOptionDelete', this.getResolve(pickupOption), (pickupOption) => {
      scope.$http.delete("/api/pickupOptions/"+pickupOption._id)
      .then(() => {
        (scope.PickupOptionsService as any).reload();
        scope.reload();
      });
    });
  }

  edit(pickupOption) {
    let scope = this;
    this.modal('adminPickupOptionEdit', this.getResolve(pickupOption), (pickupOption) => {
      (scope.PickupOptionsService as any).reload();
      scope.reload();
    });
  }

  create() {
    let scope = this;
    this.modal('adminPickupOptionEdit', this.getResolve(null), (pickupOption) => {
      (scope.PickupOptionsService as any).reload();
      scope.reload();
    });
  }

  reload() {
    (this.PickupOptionsService as any).get()
    .then(pickupOptions => {
      this.pickupOptions = pickupOptions;
    });
  }
}

export default angular.module('terrappApp.adminPickupOptions', [uiRouter])
  .config(routes)
  .component('adminPickupOptions', {
    template: require('./adminPickupOptions.html'),
    controller: AdminPickupOptionsComponent,
    controllerAs: '$ctrl'
  })
  .name;


text:
sparked is a remote push-to-deploy system for arduino

---

##Usage:
1. Hook arduino up to slave computer
* Install sparked on computer
* Set up a slack bot for sparked (if integrating with slack, otherwise leave blank)
* Run sparked, and tell it which file to pull, include auth token if needed (for private repos). Also include slack bot info if integrating with slack
* Sparked will automatically download, build, verify, and deploy to arduino if the .ino file passes verification. If not, sparked will send an error through slack
* While running, sparked will stream output from serial output once the command ```start talking``` is used in a private message or in a channel that sparked's bot is in
* If watching a private repository, your link will look something like ```https://raw.githubusercontent.com/UserName/Repo/Branch/File.ino?token=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA```. This token seems to be generated on a per-file basis, so you'll have to include the full file name (including token)

##Slack Integration:
sparked can send serial output to slack. Type these commands in slack to interact with sparked. Type these commands alone if you're direct messaging the bot, but prefix these commands with an @[bot's name] if in a channel.
* ```help``` to display all of these commands
* ```example``` to display examples for all of these commands
* ```status``` to output current sparked status
* ```refetch, reupload, upload,``` or ```update``` to manually fetch the file, upload it to the arduino and restart. Also should be used to update after baud and port changes have been finalized, otherwise the changes will not come into effect. If the file cannot be downloaded, sparked will use the last file it has downloaded instead
* ```baud [new baud rate]``` to change baud rate
* ```list``` to list serial devices
* ```port [device port name]``` to change the port that sparked reads serial output from and uploads files to
* ```file [raw github file url]``` to switch to a new file url to monitor and upload
* ```print [message to send]``` to input a message into serial input. Additionally, you can print to serial similarly to how you would on arduino, with ```print("data here")```
* ```start``` to start outputting serial data in that channel/private message
* ```stop``` to stop outputting serial data in that channel/private message
* ```quit``` to quit dosparked

---

##Setup:
* Install avrdude
* ```npm install -g sparked```

---

##License:
###MIT


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.manning.sdmia</groupId>
	<artifactId>ch07-jdbc-datasource</artifactId>
	<packaging>bundle</packaging>
	<name>ch07-jdbc-datasource</name>
	<description>Data source.</description>
	<version>1.0-SNAPSHOT</version>
	<url>http://maven.apache.org</url>

	<properties>
		<felix.bundle.plugin.version>2.0.0</felix.bundle.plugin.version>
	</properties>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>${felix.bundle.plugin.version}</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Import-Package>com.mchange.v2.c3p0;version="0.9.1.2",org.hsqldb;version="1.8.0.9",org.springframework.beans.factory.config;version="2.5.5",org.springframework.context;version="2.5.5"</Import-Package>
					</instructions>
				</configuration>
			</plugin>
		</plugins>

	</build>

</project>


text:
'''This module provides function for working with significant
figures.'''
import types, re, string

epat = re.compile(r'^([^e]+)e(.+)$')

def round_sig(x, n, scien_notation = False):
    if x < 0:
        x = x * -1
        symbol = '-'
    else:
        symbol = ''

    '''round floating point x to n significant figures'''
    if type(n) is not types.IntType:
        raise TypeError, "n must be an integer"
    try:
        x = float(x)
    except:
        raise TypeError, "x must be a floating point object"
    form = "%0." + str(n-1) + "e"
    st = form % x
    num,expo = epat.findall(st)[0]
    expo = int(expo)
    fs = string.split(num,'.')
    if len(fs) < 2:
        fs = [fs[0],""]
    if expo == 0:
#         print 'One', num
        return symbol + num
    elif expo > 0:
        if len(fs[1]) < expo:
            fs[1] += "0"*(expo-len(fs[1]))
        st = fs[0]+fs[1][0:expo]
        if len(fs[1][expo:]) > 0:
            st += '.'+fs[1][expo:]
#         print 'Two', st
        return symbol + st
    else:
        expo = -expo
        if fs[0][0] == '-':
            fs[0] = fs[0][1:]
            sign = "-"
        else:
            sign = ""

        if scien_notation:
            coso = float(sign+"0."+"0"*(expo-1)+fs[0]+fs[1])
            scient_format = '{:.' + str(n) + 'e}'
            StrScientific = scient_format.format(coso)
#             print 'three', StrScientific
            return symbol + StrScientific

        else:
            formated = sign+"0."+"0"*(expo-1)+fs[0]+fs[1]
            if len(formated) > (n+5):
                formated = '0.' + '0' * n
#             print 'cuantro', formated
            return symbol + formated

def round_sig_error(x, ex, n, paren=False):
    '''Find ex rounded to n sig-figs and make the floating point x
    match the number of decimals.  If [paren], the string is
    returned as quantity(error) format'''
    stex = round_sig(ex,n)
    if stex.find('.') < 0:
        extra_zeros = len(stex) - n
        sigfigs = len(str(int(x))) - extra_zeros
        stx = round_sig(x,sigfigs)
    else:
        num_after_dec = len(string.split(stex,'.')[1])
        stx = ("%%.%df" % num_after_dec) % (x)
    if paren:
        if stex.find('.') >= 0:
            stex = stex[stex.find('.')+1:]
        return "%s(%s)" % (stx,stex)
    return stx,stex

def format_table(cols, errors, n, labels=None, headers=None, latex=False):
    '''Format a table such that the errors have n significant
    figures.  [cols] and [errors] should be a list of 1D arrays
    that correspond to data and errors in columns.  [n] is the number of
    significant figures to keep in the errors.  [labels] is an optional
    column of strings that will be in the first column.  [headers] is
    an optional list of column headers.  If [latex] is true, myformat
    the table so that it can be included in a LaTeX table '''
    if len(cols) != len(errors):
        raise ValueError, "Error:  cols and errors must have same length"

    ncols = len(cols)
    nrows = len(cols[0])

    if headers is not None:
        if labels is not None:
            if len(headers) == ncols:
                headers = [""] + headers
            elif len(headers) == ncols+1:
                pass
            else:
                raise ValueError, "length of headers should be %d" % (ncols+1)
        else:
            if len(headers) != ncols:
                raise ValueError, "length of headers should be %d" % (ncols)

    if labels is not None:
        if len(labels) != nrows:
            raise ValueError, "length of labels should be %d" % (nrows)

    strcols = []
    for col,error in zip(cols,errors):
        strcols.append([])
        strcols.append([])
        for i in range(nrows):
            val,err = round_sig_error(col[i], error[i], n)
            strcols[-2].append(val)
            strcols[-1].append(err)

    lengths = [max([len(item) for item in strcol]) for strcol in strcols]
    myformat = ""
    if labels is not None:
        myformat += "%%%ds " % (max(map(len, labels)))
        if latex:
            myformat += "& "
    for length in lengths:
        myformat += "%%%ds " % (length)
        if latex:
            myformat += "& "
    if latex:
        myformat = myformat[:-2] + " \\\\"
    output = []
    if headers:
        if labels:
            hs = [headers[0]]
            for head in headers[1:]:
                hs.append(head)
                hs.append('+/-')
        else:
            hs = []
            for head in headers:
                hs.append(head)
                hs.append('+/-')
        output.append(myformat % tuple(hs))
    for i in range(nrows):
        if labels is not None:
            output.append(myformat % tuple([labels[i]] + [strcol[i] for strcol in strcols]))
        else:
            output.append(myformat % tuple([strcol[i] for strcol in strcols]))
    return output

def round_sig_error2(x, ex1, ex2, n):
    '''Find min(ex1,ex2) rounded to n sig-figs and make the floating point x
    and max(ex,ex2) match the number of decimals.'''
    minerr = min(ex1,ex2)
    minstex = round_sig(minerr,n)
    if minstex.find('.') < 0:
        extra_zeros = len(minstex) - n
        sigfigs = len(str(int(x))) - extra_zeros
        stx = round_sig(x,sigfigs)
        maxstex = round_sig(max(ex1,ex2),sigfigs)
    else:
        num_after_dec = len(string.split(minstex,'.')[1])
        stx = ("%%.%df" % num_after_dec) % (x)
        maxstex = ("%%.%df" % num_after_dec) % (max(ex1,ex2))
    if ex1 < ex2:
        return stx,minstex,maxstex
    else:
        return stx,maxstex,minstex


text:
require('./common');
var python = py;

describe('node-python', function () {
    describe('eval', function () {
        it('should return resulting value from python statement executed', function () {
            var value = python.eval('"1"');
            value.should.equal("1");
        });
        it('should return resulting value from python statement executed, converting to string with complex types', function () {
            var decimal = python.import('decimal');
            var smallNum = decimal.Decimal('0.0000000001');
            smallNum.toString().should.equal('1E-10');
        });
    });
    describe('import', function () {
        it('should return object representing module imported, containing functions from imported module', function () {
            var value = python.import('decimal');
            value.should.have.property('valueOf');
        });
        it('should throw a PythonError when importing a module that does not exist', function () {
            expect(function () {
                python.import('jibberish');
            }).throw(/No module named \'jibberish\'/);
        });
        it('should throw an Error when importing a module that includes bad syntax', function () {
            expect(function () {
                python.import('test.support.test');
            }).throw(/invalid syntax/)
        });
    });
    it('should convert javascript null to python NoneType', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName(null);
        type.should.equal('NoneType');
    });
    it('should convert javascript undefined to python NoneType', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName(undefined);
        type.should.equal('NoneType');
    });
    it('should convert javascript booleans to python booleans', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName(true);
        type.should.equal('bool');
    });
    it('should convert javascript date to python date', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName(new Date());
        type.should.equal('datetime');
    });
    it('should convert javascript numbers to python floats', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName(1);
        type.should.equal('float');
    });
    it('should convert javascript arrays to python list', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName([]);
        type.should.equal('list');
    });
    it('should convert javascript objects to python dictionaries', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName({});
        type.should.equal('dict');
    });
    it('should convert javascript nested objects correctly', function () {
        test = python.import('test.support.test2');
        var type = test.getPythonTypeName2({
            value: 1
        }, 'value');
        type.should.equal('float');
        var type = test.getPythonTypeName2({
            value: true
        }, 'value');
        type.should.equal('bool');
        var type = test.getPythonTypeName2({
            value: new Date()
        }, 'value');
        type.should.equal('datetime');
        var type = test.getPythonTypeName2({
            value: {}
        }, 'value');
        type.should.equal('dict');
        var type = test.getPythonTypeName2({
            value: ['one', 'two', 'three']
        }, 'value');
        type.should.equal('list');
        var i = 0, arr = [];
        while (i < 10000) {
            arr.push(Math.random().toString())
                i++;
        }
        var type = test.getPythonTypeName(arr);
        type.should.equal('list');
    });
    it('should convert python dicts to javascript objects', function () {
        test = python.import('test.support.test2');
        var value = test.getPythonValue({
            value: 1
        });
        value.should.have.property('value', 1);
    });
    it('should convert python lists to javascript arrays', function () {
        test = python.import('test.support.test2');
        var value = test.getPythonValue([ 1, 2, 3]);
        value.should.contain(1);
        value.should.contain(2);
        value.should.contain(3);
    });
});


text:
package com.taobao.tddl.rule.enumerator.handler;

import java.util.Calendar;
import java.util.Date;
import java.util.Set;

import com.taobao.tddl.common.utils.thread.ThreadLocalMap;
import com.taobao.tddl.rule.model.DateEnumerationParameter;
import com.taobao.tddl.rule.model.sqljep.Comparative;

/**
 * 基于时间类型的枚举器
 *
 * @author jianghang 2013-10-29 下午5:23:01
 * @since 5.0.0
 */
public class DatePartDiscontinousRangeEnumerator extends PartDiscontinousRangeEnumerator {

    private static final long   LIMIT_UNIT_OF_DATE        = 1L;
    private static final String DATE_ENUMERATOR           = "DATE_ENUMERATOR";
    private static final int    DEFAULT_DATE_ATOMIC_VALUE = 1;

    @Override
    protected Comparative changeGreater2GreaterOrEq(Comparative from) {
        if (from.getComparison() == Comparative.GreaterThan) {
            Date gtDate = (Date) from.getValue();
            long gtOrEqDate = gtDate.getTime() + LIMIT_UNIT_OF_DATE;
            return new Comparative(Comparative.GreaterThanOrEqual, new Date(gtOrEqDate));

        }
        return from;
    }

    @Override
    protected Comparative changeLess2LessOrEq(Comparative to) {
        if (to.getComparison() == Comparative.LessThan) {
            Date less = (Date) to.getValue();
            long lessOrEqDate = less.getTime() - LIMIT_UNIT_OF_DATE;
            return new Comparative(Comparative.LessThanOrEqual, new Date(lessOrEqDate));
        }
        return to;
    }

    @SuppressWarnings("rawtypes")
    @Override
    protected Comparable getOneStep(Comparable source, Comparable atomIncVal) {
        DateEnumerationParameter dateEnumerationParameter = getDateEnumerationParameter(atomIncVal);
        Calendar cal = getCalendar((Date) source);
        cal.add(dateEnumerationParameter.calendarFieldType, dateEnumerationParameter.atomicIncreatementNumber);
        return cal.getTime();
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    protected boolean inputCloseRangeGreaterThanMaxFieldOfDifination(Comparable from, Comparable to,
                                                                     Integer cumulativeTimes,
                                                                     Comparable<?> atomIncrValue) {
        if (cumulativeTimes == null) {
            return false;
        }
        Calendar cal = getCalendar((Date) from);
        int rangeSet = cumulativeTimes;
        if (atomIncrValue instanceof Integer) {
            // 兼容老实现,对应#gmt,1,7#这种
            cal.add(Calendar.DATE, rangeSet * (Integer) atomIncrValue);
        } else if (atomIncrValue instanceof DateEnumerationParameter) {
            // 对应#gmt,1_month,12这样的情况
            DateEnumerationParameter dep = (DateEnumerationParameter) atomIncrValue;
            cal.add(dep.calendarFieldType, rangeSet * dep.atomicIncreatementNumber);
        } else if (atomIncrValue == null) {
            // 兼容老实现,对应没有#gmt#.这种普通的情况,
            cal.add(Calendar.DATE, rangeSet);
        } else {
            throwNotSupportIllegalArgumentException(atomIncrValue);
        }

        if (to.compareTo(cal.getTime()) >= 0) {
            return true;
        }
        return false;
    }

    private void throwNotSupportIllegalArgumentException(Object arg) {
        throw new IllegalArgumentException("不能识别的类型:" + arg + " .type is" + arg.getClass());
    }

    public void processAllPassableFields(Comparative begin, Set<Object> retValue, Integer cumulativeTimes,
                                         Comparable<?> atomicIncreationValue) {
        DateEnumerationParameter dateEnumerationParameter = getDateEnumerationParameter(atomicIncreationValue);
        // 把> < 替换为>= <=
        begin = changeGreater2GreaterOrEq(begin);
        begin = changeLess2LessOrEq(begin);

        Calendar cal = getCalendar((Date) begin.getValue());
        int comparasion = begin.getComparison();
        if (comparasion == Comparative.GreaterThanOrEqual) {
            // 添加当前时间,因为当前时间内已经是大于等于了。
            retValue.add(cal.getTime());
            // 减少一次迭代,因为已经加了当前时间
            for (int i = 0; i < cumulativeTimes - 1; i++) {
                cal.add(dateEnumerationParameter.calendarFieldType, dateEnumerationParameter.atomicIncreatementNumber);
                retValue.add(cal.getTime());
            }
        } else if (comparasion == Comparative.LessThanOrEqual) {
            retValue.add(cal.getTime());
            for (int i = 0; i < cumulativeTimes - 1; i++) {
                cal.add(dateEnumerationParameter.calendarFieldType, -1
                                                                    * dateEnumerationParameter.atomicIncreatementNumber);
                retValue.add(cal.getTime());
            }
        }
    }

    /**
     * 识别data自增参数
     */
    protected DateEnumerationParameter getDateEnumerationParameter(Comparable<?> comparable) {
        DateEnumerationParameter dateEnumerationParameter = null;
        if (comparable == null) {
            dateEnumerationParameter = new DateEnumerationParameter(DEFAULT_DATE_ATOMIC_VALUE);
        } else if (comparable instanceof Integer) {
            dateEnumerationParameter = new DateEnumerationParameter((Integer) comparable);
        } else if (comparable instanceof DateEnumerationParameter) {
            dateEnumerationParameter = (DateEnumerationParameter) comparable;
        } else {
            throwNotSupportIllegalArgumentException(comparable);
        }
        return dateEnumerationParameter;
    }

    private Calendar getCalendar(Date date2BeSet) {
        // 优化重用一下Calendar
        Calendar cal = (Calendar) ThreadLocalMap.get(DATE_ENUMERATOR);
        if (cal == null) {
            cal = Calendar.getInstance();
            ThreadLocalMap.put(DATE_ENUMERATOR, cal);
        }
        cal.setTime(date2BeSet);
        return cal;
    }
}