text:
declare var NEAppProxyErrorDomain: string;

declare class NEAppProxyFlow extends NSObject {

	static alloc(): NEAppProxyFlow; // inherited from NSObject

	static new(): NEAppProxyFlow; // inherited from NSObject

	/* readonly */ metaData: NEFlowMetaData;

	closeReadWithError(error: NSError): void;

	closeWriteWithError(error: NSError): void;

	openWithLocalEndpointCompletionHandler(localEndpoint: NWHostEndpoint, completionHandler: (p1: NSError) => void): void;
}

declare const enum NEAppProxyFlowError {

	NotConnected = 1,

	PeerReset = 2,

	HostUnreachable = 3,

	InvalidArgument = 4,

	Aborted = 5,

	Refused = 6,

	TimedOut = 7,

	Internal = 8,

	DatagramTooLarge = 9,

	ReadAlreadyPending = 10
}

declare class NEAppProxyProvider extends NETunnelProvider {

	static alloc(): NEAppProxyProvider; // inherited from NSObject

	static new(): NEAppProxyProvider; // inherited from NSObject

	cancelProxyWithError(error: NSError): void;

	handleNewFlow(flow: NEAppProxyFlow): boolean;

	startProxyWithOptionsCompletionHandler(options: NSDictionary<string, any>, completionHandler: (p1: NSError) => void): void;

	stopProxyWithReasonCompletionHandler(reason: NEProviderStopReason, completionHandler: () => void): void;
}

declare class NEAppProxyProviderManager extends NETunnelProviderManager {

	static alloc(): NEAppProxyProviderManager; // inherited from NSObject

	static new(): NEAppProxyProviderManager; // inherited from NSObject
}

declare class NEAppProxyTCPFlow extends NEAppProxyFlow {

	static alloc(): NEAppProxyTCPFlow; // inherited from NSObject

	static new(): NEAppProxyTCPFlow; // inherited from NSObject

	/* readonly */ remoteEndpoint: NWEndpoint;

	readDataWithCompletionHandler(completionHandler: (p1: NSData, p2: NSError) => void): void;

	writeDataWithCompletionHandler(data: NSData, completionHandler: (p1: NSError) => void): void;
}

declare class NEAppProxyUDPFlow extends NEAppProxyFlow {

	static alloc(): NEAppProxyUDPFlow; // inherited from NSObject

	static new(): NEAppProxyUDPFlow; // inherited from NSObject

	/* readonly */ localEndpoint: NWEndpoint;

	readDatagramsWithCompletionHandler(completionHandler: (p1: NSArray<NSData>, p2: NSArray<NWEndpoint>, p3: NSError) => void): void;

	writeDatagramsSentByEndpointsCompletionHandler(datagrams: NSArray<NSData>, remoteEndpoints: NSArray<NWEndpoint>, completionHandler: (p1: NSError) => void): void;
}

declare class NEAppRule extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEAppRule; // inherited from NSObject

	static new(): NEAppRule; // inherited from NSObject

	matchDomains: NSArray<any>;

	matchPath: string;

	/* readonly */ matchSigningIdentifier: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { signingIdentifier: string; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithSigningIdentifier(signingIdentifier: string): this;
}

declare class NEDNSSettings extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEDNSSettings; // inherited from NSObject

	static new(): NEDNSSettings; // inherited from NSObject

	domainName: string;

	matchDomains: NSArray<string>;

	matchDomainsNoSearch: boolean;

	searchDomains: NSArray<string>;

	/* readonly */ servers: NSArray<string>;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { servers: NSArray<string>; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithServers(servers: NSArray<string>): this;
}

declare class NEEvaluateConnectionRule extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEEvaluateConnectionRule; // inherited from NSObject

	static new(): NEEvaluateConnectionRule; // inherited from NSObject

	/* readonly */ action: NEEvaluateConnectionRuleAction;

	/* readonly */ matchDomains: NSArray<string>;

	probeURL: NSURL;

	useDNSServers: NSArray<string>;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { matchDomains: NSArray<string>; andAction: NEEvaluateConnectionRuleAction; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithMatchDomainsAndAction(domains: NSArray<string>, action: NEEvaluateConnectionRuleAction): this;
}

declare const enum NEEvaluateConnectionRuleAction {

	ConnectIfNeeded = 1,

	NeverConnect = 2
}

declare class NEFilterBrowserFlow extends NEFilterFlow implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterBrowserFlow; // inherited from NSObject

	static new(): NEFilterBrowserFlow; // inherited from NSObject

	/* readonly */ parentURL: NSURL;

	/* readonly */ request: NSURLRequest;

	/* readonly */ response: NSURLResponse;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare var NEFilterConfigurationDidChangeNotification: string;

declare class NEFilterControlProvider extends NEFilterProvider {

	static alloc(): NEFilterControlProvider; // inherited from NSObject

	static new(): NEFilterControlProvider; // inherited from NSObject

	URLAppendStringMap: NSDictionary<string, string>;

	remediationMap: NSDictionary<string, NSDictionary<string, NSObject>>;

	handleNewFlowCompletionHandler(flow: NEFilterFlow, completionHandler: (p1: NEFilterControlVerdict) => void): void;

	handleRemediationForFlowCompletionHandler(flow: NEFilterFlow, completionHandler: (p1: NEFilterControlVerdict) => void): void;

	notifyRulesChanged(): void;
}

declare class NEFilterControlVerdict extends NEFilterNewFlowVerdict implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterControlVerdict; // inherited from NSObject

	static allowVerdictWithUpdateRules(updateRules: boolean): NEFilterControlVerdict;

	static dropVerdictWithUpdateRules(updateRules: boolean): NEFilterControlVerdict;

	static new(): NEFilterControlVerdict; // inherited from NSObject

	static updateRules(): NEFilterControlVerdict;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFilterDataProvider extends NEFilterProvider {

	static alloc(): NEFilterDataProvider; // inherited from NSObject

	static new(): NEFilterDataProvider; // inherited from NSObject

	handleInboundDataCompleteForFlow(flow: NEFilterFlow): NEFilterDataVerdict;

	handleInboundDataFromFlowReadBytesStartOffsetReadBytes(flow: NEFilterFlow, offset: number, readBytes: NSData): NEFilterDataVerdict;

	handleNewFlow(flow: NEFilterFlow): NEFilterNewFlowVerdict;

	handleOutboundDataCompleteForFlow(flow: NEFilterFlow): NEFilterDataVerdict;

	handleOutboundDataFromFlowReadBytesStartOffsetReadBytes(flow: NEFilterFlow, offset: number, readBytes: NSData): NEFilterDataVerdict;

	handleRemediationForFlow(flow: NEFilterFlow): NEFilterRemediationVerdict;

	handleRulesChanged(): void;
}

declare class NEFilterDataVerdict extends NEFilterVerdict implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterDataVerdict; // inherited from NSObject

	static allowVerdict(): NEFilterDataVerdict;

	static dataVerdictWithPassBytesPeekBytes(passBytes: number, peekBytes: number): NEFilterDataVerdict;

	static dropVerdict(): NEFilterDataVerdict;

	static needRulesVerdict(): NEFilterDataVerdict;

	static new(): NEFilterDataVerdict; // inherited from NSObject

	static remediateVerdictWithRemediationURLMapKeyRemediationButtonTextMapKey(remediationURLMapKey: string, remediationButtonTextMapKey: string): NEFilterDataVerdict;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare var NEFilterErrorDomain: string;

declare class NEFilterFlow extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterFlow; // inherited from NSObject

	static new(): NEFilterFlow; // inherited from NSObject

	/* readonly */ URL: NSURL;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFilterManager extends NSObject {

	static alloc(): NEFilterManager; // inherited from NSObject

	static new(): NEFilterManager; // inherited from NSObject

	static sharedManager(): NEFilterManager;

	enabled: boolean;

	localizedDescription: string;

	providerConfiguration: NEFilterProviderConfiguration;

	loadFromPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;

	removeFromPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;

	saveToPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;
}

declare const enum NEFilterManagerError {

	ConfigurationInvalid = 1,

	ConfigurationDisabled = 2,

	ConfigurationStale = 3,

	ConfigurationCannotBeRemoved = 4
}

declare class NEFilterNewFlowVerdict extends NEFilterVerdict implements NSCopying, NSSecureCoding {

	static URLAppendStringVerdictWithMapKey(urlAppendMapKey: string): NEFilterNewFlowVerdict;

	static alloc(): NEFilterNewFlowVerdict; // inherited from NSObject

	static allowVerdict(): NEFilterNewFlowVerdict;

	static dropVerdict(): NEFilterNewFlowVerdict;

	static filterDataVerdictWithFilterInboundPeekInboundBytesFilterOutboundPeekOutboundBytes(filterInbound: boolean, peekInboundBytes: number, filterOutbound: boolean, peekOutboundBytes: number): NEFilterNewFlowVerdict;

	static needRulesVerdict(): NEFilterNewFlowVerdict;

	static new(): NEFilterNewFlowVerdict; // inherited from NSObject

	static remediateVerdictWithRemediationURLMapKeyRemediationButtonTextMapKey(remediationURLMapKey: string, remediationButtonTextMapKey: string): NEFilterNewFlowVerdict;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFilterProvider extends NEProvider {

	static alloc(): NEFilterProvider; // inherited from NSObject

	static new(): NEFilterProvider; // inherited from NSObject

	/* readonly */ filterConfiguration: NEFilterProviderConfiguration;

	startFilterWithCompletionHandler(completionHandler: (p1: NSError) => void): void;

	stopFilterWithReasonCompletionHandler(reason: NEProviderStopReason, completionHandler: () => void): void;
}

declare class NEFilterProviderConfiguration extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterProviderConfiguration; // inherited from NSObject

	static new(): NEFilterProviderConfiguration; // inherited from NSObject

	filterBrowsers: boolean;

	filterSockets: boolean;

	identityReference: NSData;

	organization: string;

	passwordReference: NSData;

	serverAddress: string;

	username: string;

	vendorConfiguration: NSDictionary<string, any>;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare var NEFilterProviderRemediationMapRemediationButtonTexts: string;

declare var NEFilterProviderRemediationMapRemediationURLs: string;

declare class NEFilterRemediationVerdict extends NEFilterVerdict implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterRemediationVerdict; // inherited from NSObject

	static allowVerdict(): NEFilterRemediationVerdict;

	static dropVerdict(): NEFilterRemediationVerdict;

	static needRulesVerdict(): NEFilterRemediationVerdict;

	static new(): NEFilterRemediationVerdict; // inherited from NSObject

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFilterSocketFlow extends NEFilterFlow implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterSocketFlow; // inherited from NSObject

	static new(): NEFilterSocketFlow; // inherited from NSObject

	/* readonly */ localEndpoint: NWEndpoint;

	/* readonly */ remoteEndpoint: NWEndpoint;

	socketFamily: number;

	socketProtocol: number;

	socketType: number;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFilterVerdict extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEFilterVerdict; // inherited from NSObject

	static new(): NEFilterVerdict; // inherited from NSObject

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEFlowMetaData extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEFlowMetaData; // inherited from NSObject

	static new(): NEFlowMetaData; // inherited from NSObject

	/* readonly */ sourceAppSigningIdentifier: string;

	/* readonly */ sourceAppUniqueIdentifier: NSData;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEHotspotHelper extends NSObject {

	static alloc(): NEHotspotHelper; // inherited from NSObject

	static logoff(network: NEHotspotNetwork): boolean;

	static new(): NEHotspotHelper; // inherited from NSObject

	static registerWithOptionsQueueHandler(options: NSDictionary<string, NSObject>, queue: NSObject, handler: (p1: NEHotspotHelperCommand) => void): boolean;

	static supportedNetworkInterfaces(): NSArray<any>;
}

declare class NEHotspotHelperCommand extends NSObject {

	static alloc(): NEHotspotHelperCommand; // inherited from NSObject

	static new(): NEHotspotHelperCommand; // inherited from NSObject

	/* readonly */ commandType: NEHotspotHelperCommandType;

	/* readonly */ network: NEHotspotNetwork;

	/* readonly */ networkList: NSArray<NEHotspotNetwork>;

	createResponse(result: NEHotspotHelperResult): NEHotspotHelperResponse;

	createTCPConnection(endpoint: NWEndpoint): NWTCPConnection;

	createUDPSession(endpoint: NWEndpoint): NWUDPSession;
}

declare const enum NEHotspotHelperCommandType {

	kNEHotspotHelperCommandTypeNone = 0,

	kNEHotspotHelperCommandTypeFilterScanList = 1,

	kNEHotspotHelperCommandTypeEvaluate = 2,

	kNEHotspotHelperCommandTypeAuthenticate = 3,

	kNEHotspotHelperCommandTypePresentUI = 4,

	kNEHotspotHelperCommandTypeMaintain = 5,

	kNEHotspotHelperCommandTypeLogoff = 6
}

declare const enum NEHotspotHelperConfidence {

	kNEHotspotHelperConfidenceNone = 0,

	kNEHotspotHelperConfidenceLow = 1,

	kNEHotspotHelperConfidenceHigh = 2
}

declare class NEHotspotHelperResponse extends NSObject {

	static alloc(): NEHotspotHelperResponse; // inherited from NSObject

	static new(): NEHotspotHelperResponse; // inherited from NSObject

	deliver(): void;

	setNetwork(network: NEHotspotNetwork): void;

	setNetworkList(networkList: NSArray<NEHotspotNetwork>): void;
}

declare const enum NEHotspotHelperResult {

	kNEHotspotHelperResultSuccess = 0,

	kNEHotspotHelperResultFailure = 1,

	kNEHotspotHelperResultUIRequired = 2,

	kNEHotspotHelperResultCommandNotRecognized = 3,

	kNEHotspotHelperResultAuthenticationRequired = 4,

	kNEHotspotHelperResultUnsupportedNetwork = 5,

	kNEHotspotHelperResultTemporaryFailure = 6
}

declare class NEHotspotNetwork extends NSObject {

	static alloc(): NEHotspotNetwork; // inherited from NSObject

	static new(): NEHotspotNetwork; // inherited from NSObject

	/* readonly */ BSSID: string;

	/* readonly */ SSID: string;

	/* readonly */ autoJoined: boolean;

	/* readonly */ chosenHelper: boolean;

	/* readonly */ justJoined: boolean;

	/* readonly */ secure: boolean;

	/* readonly */ signalStrength: number;

	setConfidence(confidence: NEHotspotHelperConfidence): void;

	setPassword(password: string): void;
}

declare class NEIPv4Route extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEIPv4Route; // inherited from NSObject

	static defaultRoute(): NEIPv4Route;

	static new(): NEIPv4Route; // inherited from NSObject

	/* readonly */ destinationAddress: string;

	/* readonly */ destinationSubnetMask: string;

	gatewayAddress: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { destinationAddress: string; subnetMask: string; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithDestinationAddressSubnetMask(address: string, subnetMask: string): this;
}

declare class NEIPv4Settings extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEIPv4Settings; // inherited from NSObject

	static new(): NEIPv4Settings; // inherited from NSObject

	/* readonly */ addresses: NSArray<string>;

	excludedRoutes: NSArray<NEIPv4Route>;

	includedRoutes: NSArray<NEIPv4Route>;

	/* readonly */ subnetMasks: NSArray<string>;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { addresses: NSArray<string>; subnetMasks: NSArray<string>; });

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithAddressesSubnetMasks(addresses: NSArray<string>, subnetMasks: NSArray<string>): this;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEIPv6Route extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEIPv6Route; // inherited from NSObject

	static defaultRoute(): NEIPv6Route;

	static new(): NEIPv6Route; // inherited from NSObject

	/* readonly */ destinationAddress: string;

	/* readonly */ destinationNetworkPrefixLength: number;

	gatewayAddress: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { destinationAddress: string; networkPrefixLength: number; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithDestinationAddressNetworkPrefixLength(address: string, networkPrefixLength: number): this;
}

declare class NEIPv6Settings extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEIPv6Settings; // inherited from NSObject

	static new(): NEIPv6Settings; // inherited from NSObject

	/* readonly */ addresses: NSArray<string>;

	excludedRoutes: NSArray<NEIPv6Route>;

	includedRoutes: NSArray<NEIPv6Route>;

	/* readonly */ networkPrefixLengths: NSArray<number>;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { addresses: NSArray<string>; networkPrefixLengths: NSArray<number>; });

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithAddressesNetworkPrefixLengths(addresses: NSArray<string>, networkPrefixLengths: NSArray<number>): this;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEOnDemandRule extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEOnDemandRule; // inherited from NSObject

	static new(): NEOnDemandRule; // inherited from NSObject

	DNSSearchDomainMatch: NSArray<string>;

	DNSServerAddressMatch: NSArray<string>;

	SSIDMatch: NSArray<string>;

	/* readonly */ action: NEOnDemandRuleAction;

	interfaceTypeMatch: NEOnDemandRuleInterfaceType;

	probeURL: NSURL;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare const enum NEOnDemandRuleAction {

	Connect = 1,

	Disconnect = 2,

	EvaluateConnection = 3,

	Ignore = 4
}

declare class NEOnDemandRuleConnect extends NEOnDemandRule {

	static alloc(): NEOnDemandRuleConnect; // inherited from NSObject

	static new(): NEOnDemandRuleConnect; // inherited from NSObject
}

declare class NEOnDemandRuleDisconnect extends NEOnDemandRule {

	static alloc(): NEOnDemandRuleDisconnect; // inherited from NSObject

	static new(): NEOnDemandRuleDisconnect; // inherited from NSObject
}

declare class NEOnDemandRuleEvaluateConnection extends NEOnDemandRule {

	static alloc(): NEOnDemandRuleEvaluateConnection; // inherited from NSObject

	static new(): NEOnDemandRuleEvaluateConnection; // inherited from NSObject

	connectionRules: NSArray<NEEvaluateConnectionRule>;
}

declare class NEOnDemandRuleIgnore extends NEOnDemandRule {

	static alloc(): NEOnDemandRuleIgnore; // inherited from NSObject

	static new(): NEOnDemandRuleIgnore; // inherited from NSObject
}

declare const enum NEOnDemandRuleInterfaceType {

	Any = 0,

	Ethernet = 1,

	WiFi = 2,

	Cellular = 3
}

declare class NEPacket extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEPacket; // inherited from NSObject

	static new(): NEPacket; // inherited from NSObject

	/* readonly */ data: NSData;

	/* readonly */ metadata: NEFlowMetaData;

	/* readonly */ protocolFamily: number;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { data: NSData; protocolFamily: number; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithDataProtocolFamily(data: NSData, protocolFamily: number): this;
}

declare class NEPacketTunnelFlow extends NSObject {

	static alloc(): NEPacketTunnelFlow; // inherited from NSObject

	static new(): NEPacketTunnelFlow; // inherited from NSObject

	readPacketObjectsWithCompletionHandler(completionHandler: (p1: NSArray<NEPacket>) => void): void;

	readPacketsWithCompletionHandler(completionHandler: (p1: NSArray<NSData>, p2: NSArray<number>) => void): void;

	writePacketObjects(packets: NSArray<NEPacket>): boolean;

	writePacketsWithProtocols(packets: NSArray<NSData>, protocols: NSArray<number>): boolean;
}

declare class NEPacketTunnelNetworkSettings extends NETunnelNetworkSettings {

	static alloc(): NEPacketTunnelNetworkSettings; // inherited from NSObject

	static new(): NEPacketTunnelNetworkSettings; // inherited from NSObject

	IPv4Settings: NEIPv4Settings;

	IPv6Settings: NEIPv6Settings;

	MTU: number;

	tunnelOverheadBytes: number;
}

declare class NEPacketTunnelProvider extends NETunnelProvider {

	static alloc(): NEPacketTunnelProvider; // inherited from NSObject

	static new(): NEPacketTunnelProvider; // inherited from NSObject

	/* readonly */ packetFlow: NEPacketTunnelFlow;

	cancelTunnelWithError(error: NSError): void;

	createTCPConnectionThroughTunnelToEndpointEnableTLSTLSParametersDelegate(remoteEndpoint: NWEndpoint, enableTLS: boolean, TLSParameters: NWTLSParameters, delegate: any): NWTCPConnection;

	createUDPSessionThroughTunnelToEndpointFromEndpoint(remoteEndpoint: NWEndpoint, localEndpoint: NWHostEndpoint): NWUDPSession;

	startTunnelWithOptionsCompletionHandler(options: NSDictionary<string, NSObject>, completionHandler: (p1: NSError) => void): void;

	stopTunnelWithReasonCompletionHandler(reason: NEProviderStopReason, completionHandler: () => void): void;
}

declare class NEProvider extends NSObject {

	static alloc(): NEProvider; // inherited from NSObject

	static new(): NEProvider; // inherited from NSObject

	/* readonly */ defaultPath: NWPath;

	createTCPConnectionToEndpointEnableTLSTLSParametersDelegate(remoteEndpoint: NWEndpoint, enableTLS: boolean, TLSParameters: NWTLSParameters, delegate: any): NWTCPConnection;

	createUDPSessionToEndpointFromEndpoint(remoteEndpoint: NWEndpoint, localEndpoint: NWHostEndpoint): NWUDPSession;

	displayMessageCompletionHandler(message: string, completionHandler: (p1: boolean) => void): void;

	sleepWithCompletionHandler(completionHandler: () => void): void;

	wake(): void;
}

declare const enum NEProviderStopReason {

	None = 0,

	UserInitiated = 1,

	ProviderFailed = 2,

	NoNetworkAvailable = 3,

	UnrecoverableNetworkChange = 4,

	ProviderDisabled = 5,

	AuthenticationCanceled = 6,

	ConfigurationFailed = 7,

	IdleTimeout = 8,

	ConfigurationDisabled = 9,

	ConfigurationRemoved = 10,

	Superceded = 11,

	UserLogout = 12,

	UserSwitch = 13,

	ConnectionFailed = 14
}

declare class NEProxyServer extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEProxyServer; // inherited from NSObject

	static new(): NEProxyServer; // inherited from NSObject

	/* readonly */ address: string;

	authenticationRequired: boolean;

	password: string;

	/* readonly */ port: number;

	username: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { address: string; port: number; });

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithAddressPort(address: string, port: number): this;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEProxySettings extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEProxySettings; // inherited from NSObject

	static new(): NEProxySettings; // inherited from NSObject

	HTTPEnabled: boolean;

	HTTPSEnabled: boolean;

	HTTPSServer: NEProxyServer;

	HTTPServer: NEProxyServer;

	autoProxyConfigurationEnabled: boolean;

	exceptionList: NSArray<string>;

	excludeSimpleHostnames: boolean;

	matchDomains: NSArray<string>;

	proxyAutoConfigurationJavaScript: string;

	proxyAutoConfigurationURL: NSURL;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NETunnelNetworkSettings extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NETunnelNetworkSettings; // inherited from NSObject

	static new(): NETunnelNetworkSettings; // inherited from NSObject

	DNSSettings: NEDNSSettings;

	proxySettings: NEProxySettings;

	/* readonly */ tunnelRemoteAddress: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	constructor(o: { tunnelRemoteAddress: string; });

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;

	initWithTunnelRemoteAddress(address: string): this;
}

declare class NETunnelProvider extends NEProvider {

	static alloc(): NETunnelProvider; // inherited from NSObject

	static new(): NETunnelProvider; // inherited from NSObject

	/* readonly */ appRules: NSArray<NEAppRule>;

	/* readonly */ protocolConfiguration: NEVPNProtocol;

	reasserting: boolean;

	/* readonly */ routingMethod: NETunnelProviderRoutingMethod;

	handleAppMessageCompletionHandler(messageData: NSData, completionHandler: (p1: NSData) => void): void;

	setTunnelNetworkSettingsCompletionHandler(tunnelNetworkSettings: NETunnelNetworkSettings, completionHandler: (p1: NSError) => void): void;
}

declare const enum NETunnelProviderError {

	NetworkSettingsInvalid = 1,

	NetworkSettingsCanceled = 2,

	NetworkSettingsFailed = 3
}

declare var NETunnelProviderErrorDomain: string;

declare class NETunnelProviderManager extends NEVPNManager {

	static alloc(): NETunnelProviderManager; // inherited from NSObject

	static loadAllFromPreferencesWithCompletionHandler(completionHandler: (p1: NSArray<NETunnelProviderManager>, p2: NSError) => void): void;

	static new(): NETunnelProviderManager; // inherited from NSObject

	/* readonly */ routingMethod: NETunnelProviderRoutingMethod;

	copyAppRules(): NSArray<NEAppRule>;
}

declare class NETunnelProviderProtocol extends NEVPNProtocol {

	static alloc(): NETunnelProviderProtocol; // inherited from NSObject

	static new(): NETunnelProviderProtocol; // inherited from NSObject

	providerBundleIdentifier: string;

	providerConfiguration: NSDictionary<string, any>;
}

declare const enum NETunnelProviderRoutingMethod {

	DestinationIP = 1,

	SourceApplication = 2
}

declare class NETunnelProviderSession extends NEVPNConnection {

	static alloc(): NETunnelProviderSession; // inherited from NSObject

	static new(): NETunnelProviderSession; // inherited from NSObject

	sendProviderMessageReturnErrorResponseHandler(messageData: NSData, error: interop.Pointer | interop.Reference<NSError>, responseHandler: (p1: NSData) => void): boolean;

	startTunnelWithOptionsAndReturnError(options: NSDictionary<string, any>): boolean;

	stopTunnel(): void;
}

declare var NEVPNConfigurationChangeNotification: string;

declare class NEVPNConnection extends NSObject {

	static alloc(): NEVPNConnection; // inherited from NSObject

	static new(): NEVPNConnection; // inherited from NSObject

	/* readonly */ connectedDate: Date;

	/* readonly */ manager: NEVPNManager;

	/* readonly */ status: NEVPNStatus;

	startVPNTunnelAndReturnError(): boolean;

	startVPNTunnelWithOptionsAndReturnError(options: NSDictionary<string, NSObject>): boolean;

	stopVPNTunnel(): void;
}

declare var NEVPNConnectionStartOptionPassword: string;

declare var NEVPNConnectionStartOptionUsername: string;

declare const enum NEVPNError {

	ConfigurationInvalid = 1,

	ConfigurationDisabled = 2,

	ConnectionFailed = 3,

	ConfigurationStale = 4,

	ConfigurationReadWriteFailed = 5,

	ConfigurationUnknown = 6
}

declare var NEVPNErrorDomain: string;

declare const enum NEVPNIKEAuthenticationMethod {

	None = 0,

	Certificate = 1,

	SharedSecret = 2
}

declare const enum NEVPNIKEv2CertificateType {

	RSA = 1,

	ECDSA256 = 2,

	ECDSA384 = 3,

	ECDSA521 = 4
}

declare const enum NEVPNIKEv2DeadPeerDetectionRate {

	None = 0,

	Low = 1,

	Medium = 2,

	High = 3
}

declare const enum NEVPNIKEv2DiffieHellmanGroup {

	GroupInvalid = 0,

	Group1 = 1,

	Group2 = 2,

	Group5 = 5,

	Group14 = 14,

	Group15 = 15,

	Group16 = 16,

	Group17 = 17,

	Group18 = 18,

	Group19 = 19,

	Group20 = 20,

	Group21 = 21
}

declare const enum NEVPNIKEv2EncryptionAlgorithm {

	AlgorithmDES = 1,

	Algorithm3DES = 2,

	AlgorithmAES128 = 3,

	AlgorithmAES256 = 4,

	AlgorithmAES128GCM = 5,

	AlgorithmAES256GCM = 6
}

declare const enum NEVPNIKEv2IntegrityAlgorithm {

	SHA96 = 1,

	SHA160 = 2,

	SHA256 = 3,

	SHA384 = 4,

	SHA512 = 5
}

declare class NEVPNIKEv2SecurityAssociationParameters extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEVPNIKEv2SecurityAssociationParameters; // inherited from NSObject

	static new(): NEVPNIKEv2SecurityAssociationParameters; // inherited from NSObject

	diffieHellmanGroup: NEVPNIKEv2DiffieHellmanGroup;

	encryptionAlgorithm: NEVPNIKEv2EncryptionAlgorithm;

	integrityAlgorithm: NEVPNIKEv2IntegrityAlgorithm;

	lifetimeMinutes: number;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEVPNManager extends NSObject {

	static alloc(): NEVPNManager; // inherited from NSObject

	static new(): NEVPNManager; // inherited from NSObject

	static sharedManager(): NEVPNManager;

	/* readonly */ connection: NEVPNConnection;

	enabled: boolean;

	localizedDescription: string;

	onDemandEnabled: boolean;

	onDemandRules: NSArray<NEOnDemandRule>;

	protocol: NEVPNProtocol;

	protocolConfiguration: NEVPNProtocol;

	loadFromPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;

	removeFromPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;

	saveToPreferencesWithCompletionHandler(completionHandler: (p1: NSError) => void): void;
}

declare class NEVPNProtocol extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NEVPNProtocol; // inherited from NSObject

	static new(): NEVPNProtocol; // inherited from NSObject

	disconnectOnSleep: boolean;

	identityData: NSData;

	identityDataPassword: string;

	identityReference: NSData;

	passwordReference: NSData;

	proxySettings: NEProxySettings;

	serverAddress: string;

	username: string;

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NEVPNProtocolIKEv2 extends NEVPNProtocolIPSec {

	static alloc(): NEVPNProtocolIKEv2; // inherited from NSObject

	static new(): NEVPNProtocolIKEv2; // inherited from NSObject

	/* readonly */ IKESecurityAssociationParameters: NEVPNIKEv2SecurityAssociationParameters;

	certificateType: NEVPNIKEv2CertificateType;

	/* readonly */ childSecurityAssociationParameters: NEVPNIKEv2SecurityAssociationParameters;

	deadPeerDetectionRate: NEVPNIKEv2DeadPeerDetectionRate;

	disableMOBIKE: boolean;

	disableRedirect: boolean;

	enablePFS: boolean;

	enableRevocationCheck: boolean;

	serverCertificateCommonName: string;

	serverCertificateIssuerCommonName: string;

	strictRevocationCheck: boolean;

	useConfigurationAttributeInternalIPSubnet: boolean;
}

declare class NEVPNProtocolIPSec extends NEVPNProtocol {

	static alloc(): NEVPNProtocolIPSec; // inherited from NSObject

	static new(): NEVPNProtocolIPSec; // inherited from NSObject

	authenticationMethod: NEVPNIKEAuthenticationMethod;

	localIdentifier: string;

	remoteIdentifier: string;

	sharedSecretReference: NSData;

	useExtendedAuthentication: boolean;
}

declare const enum NEVPNStatus {

	Invalid = 0,

	Disconnected = 1,

	Connecting = 2,

	Connected = 3,

	Reasserting = 4,

	Disconnecting = 5
}

declare var NEVPNStatusDidChangeNotification: string;

declare class NWBonjourServiceEndpoint extends NWEndpoint {

	static alloc(): NWBonjourServiceEndpoint; // inherited from NSObject

	static endpointWithNameTypeDomain(name: string, type: string, domain: string): NWBonjourServiceEndpoint;

	static new(): NWBonjourServiceEndpoint; // inherited from NSObject

	/* readonly */ domain: string;

	/* readonly */ name: string;

	/* readonly */ type: string;
}

declare class NWEndpoint extends NSObject implements NSCopying, NSSecureCoding {

	static alloc(): NWEndpoint; // inherited from NSObject

	static new(): NWEndpoint; // inherited from NSObject

	/* readonly */ static supportsSecureCoding: boolean; // inherited from NSSecureCoding

	constructor(o: { coder: NSCoder; }); // inherited from NSCoding

	copyWithZone(zone: interop.Pointer | interop.Reference<any>): any;

	encodeWithCoder(aCoder: NSCoder): void;

	initWithCoder(aDecoder: NSCoder): this;
}

declare class NWHostEndpoint extends NWEndpoint {

	static alloc(): NWHostEndpoint; // inherited from NSObject

	static endpointWithHostnamePort(hostname: string, port: string): NWHostEndpoint;

	static new(): NWHostEndpoint; // inherited from NSObject

	/* readonly */ hostname: string;

	/* readonly */ port: string;
}

declare class NWPath extends NSObject {

	static alloc(): NWPath; // inherited from NSObject

	static new(): NWPath; // inherited from NSObject

	/* readonly */ expensive: boolean;

	/* readonly */ status: NWPathStatus;

	isEqualToPath(path: NWPath): boolean;
}

declare const enum NWPathStatus {

	Invalid = 0,

	Satisfied = 1,

	Unsatisfied = 2,

	Satisfiable = 3
}

declare class NWTCPConnection extends NSObject {

	static alloc(): NWTCPConnection; // inherited from NSObject

	static new(): NWTCPConnection; // inherited from NSObject

	/* readonly */ connectedPath: NWPath;

	/* readonly */ endpoint: NWEndpoint;

	/* readonly */ error: NSError;

	/* readonly */ hasBetterPath: boolean;

	/* readonly */ localAddress: NWEndpoint;

	/* readonly */ remoteAddress: NWEndpoint;

	/* readonly */ state: NWTCPConnectionState;

	/* readonly */ txtRecord: NSData;

	/* readonly */ viable: boolean;

	constructor(o: { upgradeForConnection: NWTCPConnection; });

	cancel(): void;

	initWithUpgradeForConnection(connection: NWTCPConnection): this;

	readLengthCompletionHandler(length: number, completion: (p1: NSData, p2: NSError) => void): void;

	readMinimumLengthMaximumLengthCompletionHandler(minimum: number, maximum: number, completion: (p1: NSData, p2: NSError) => void): void;

	writeClose(): void;

	writeCompletionHandler(data: NSData, completion: (p1: NSError) => void): void;
}

interface NWTCPConnectionAuthenticationDelegate extends NSObjectProtocol {

	evaluateTrustForConnectionPeerCertificateChainCompletionHandler?(connection: NWTCPConnection, peerCertificateChain: NSArray<any>, completion: (p1: any) => void): void;

	provideIdentityForConnectionCompletionHandler?(connection: NWTCPConnection, completion: (p1: any, p2: NSArray<any>) => void): void;

	shouldEvaluateTrustForConnection?(connection: NWTCPConnection): boolean;

	shouldProvideIdentityForConnection?(connection: NWTCPConnection): boolean;
}
declare var NWTCPConnectionAuthenticationDelegate: {

	prototype: NWTCPConnectionAuthenticationDelegate;
};

declare const enum NWTCPConnectionState {

	Invalid = 0,

	Connecting = 1,

	Waiting = 2,

	Connected = 3,

	Disconnected = 4,

	Cancelled = 5
}

declare class NWTLSParameters extends NSObject {

	static alloc(): NWTLSParameters; // inherited from NSObject

	static new(): NWTLSParameters; // inherited from NSObject

	SSLCipherSuites: NSSet<number>;

	TLSSessionID: NSData;

	maximumSSLProtocolVersion: number;

	minimumSSLProtocolVersion: number;
}

declare class NWUDPSession extends NSObject {

	static alloc(): NWUDPSession; // inherited from NSObject

	static new(): NWUDPSession; // inherited from NSObject

	/* readonly */ currentPath: NWPath;

	/* readonly */ endpoint: NWEndpoint;

	/* readonly */ hasBetterPath: boolean;

	/* readonly */ maximumDatagramLength: number;

	/* readonly */ resolvedEndpoint: NWEndpoint;

	/* readonly */ state: NWUDPSessionState;

	/* readonly */ viable: boolean;

	constructor(o: { upgradeForSession: NWUDPSession; });

	cancel(): void;

	initWithUpgradeForSession(session: NWUDPSession): this;

	setReadHandlerMaxDatagrams(handler: (p1: NSArray<NSData>, p2: NSError) => void, maxDatagrams: number): void;

	tryNextResolvedEndpoint(): void;

	writeDatagramCompletionHandler(datagram: NSData, completionHandler: (p1: NSError) => void): void;

	writeMultipleDatagramsCompletionHandler(datagramArray: NSArray<NSData>, completionHandler: (p1: NSError) => void): void;
}

declare const enum NWUDPSessionState {

	Invalid = 0,

	Waiting = 1,

	Preparing = 2,

	Ready = 3,

	Failed = 4,

	Cancelled = 5
}

declare var kNEHotspotHelperOptionDisplayName: string;


text:
/*!
 * main entrance
**/

var glob = require('./glob')
,setting = h5.setting
,local = h5.local
,tools = require('./lib/tools')
,log = tools.log
,_ = require('lodash')

try {
	require('./index.js')
}
catch(e) {
	log(e, 'error', 'init failed')
}

redpajama_set_name: RedPajamaGithub


text:
module Metriks::Reporter
  class ProcTitle
    def initialize(options = {})
      @rounding = options[:rounding] || 1
      @prefix   = options[:prefix]   || $0.dup

      @interval  = options[:interval] || 5
      @on_error  = options[:on_error] || proc { |ex| }

      @metrics  = []
    end

    def add(name, suffix = nil, &block)
      @metrics << [ name, suffix, block ]
    end

    def empty?
      @metrics.empty?
    end

    def start
      @thread ||= Thread.new do
        loop do
          begin
            unless @metrics.empty?
              title = generate_title
              if title && !title.empty?
                $0 = "#{@prefix} #{title}"
              end
            end
          rescue Exception => ex
            @on_error[ex] rescue nil
          end
          sleep @interval
        end
      end
    end

    def stop
      @thread.kill if @thread
      @thread = nil
    end

    def restart
      stop
      start
    end

    protected
    def generate_title
      @metrics.collect do |name, suffix, block|
        val = block.call
        val = "%.#{@rounding}f" % val if val.is_a?(Float)

        "#{name}: #{val}#{suffix}"
      end.join(' ')
    end
  end
end


text:
package org.n52.iceland.exception.ows.concrete;

import static org.n52.iceland.util.http.HTTPStatus.INTERNAL_SERVER_ERROR;

import org.n52.iceland.coding.encode.Encoder;
import org.n52.iceland.exception.ows.NoApplicableCodeException;

/**
 * @author Christian Autermann
 * @author Eike Hinderk
 *         Jürrens
 *
 * @since 1.0.0
 */
public class UnsupportedEncoderInputException extends NoApplicableCodeException {
    private static final long serialVersionUID = 7033551424176154646L;

    public UnsupportedEncoderInputException(final Encoder<?, ?> encoder, final Object o) {
        if (o == null) {
            withMessage("Encoder %s can not encode 'null'", encoder.getClass().getName());
        } else {
            withMessage("%s can not be encoded by Encoder %s because it is not yet implemented!", o.getClass()
                    .getName(), encoder.getClass().getName());
        }
        setStatus(INTERNAL_SERVER_ERROR);
    }
}


text:
import mock

from tests.compat import unittest
from tests.utils import APITestCase

import evelink.api as evelink_api
import evelink.char as evelink_char

API_RESULT_SENTINEL = evelink_api.APIResult(mock.sentinel.api_result, 12345, 67890)

class CharTestCase(APITestCase):

    def setUp(self):
        super(CharTestCase, self).setUp()
        self.char = evelink_char.Char(1, api=self.api)

    @mock.patch('evelink.char.parse_assets')
    def test_assets(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_assets

        result, current, expires = self.char.assets()
        self.assertEqual(result, mock.sentinel.parsed_assets)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/AssetList', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_bookmarks')
    def test_bookmarks(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_bookmarks

        result, current, expires = self.char.bookmarks()
        self.assertEqual(result, mock.sentinel.parsed_bookmarks)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Bookmarks', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_contract_bids')
    def test_contract_bids(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_contract_bids

        result, current, expires = self.char.contract_bids()
        self.assertEqual(result, mock.sentinel.parsed_contract_bids)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/ContractBids', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_contract_items')
    def test_contract_items(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_contract_items

        result, current, expires = self.char.contract_items(12345)
        self.assertEqual(result, mock.sentinel.parsed_contract_items)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/ContractItems', params={'characterID': 1, 'contractID': 12345}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_contracts')
    def test_contracts(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_contracts

        result, current, expires = self.char.contracts()
        self.assertEqual(result, mock.sentinel.parsed_contracts)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Contracts', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_wallet_journal')
    def test_wallet_journal(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_journal

        result, current, expires = self.char.wallet_journal()
        self.assertEqual(result, mock.sentinel.parsed_journal)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletJournal', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_wallet_paged(self):
        self.api.get.return_value = self.make_api_result("char/wallet_journal.xml")

        self.char.wallet_journal(before_id=1234)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletJournal', params={'characterID': 1, 'fromID': 1234}),
            ])

    def test_wallet_limit(self):
        self.api.get.return_value = self.make_api_result("char/wallet_journal.xml")

        self.char.wallet_journal(limit=100)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletJournal', params={'characterID': 1, 'rowCount': 100}),
            ])

    def test_wallet_info(self):
        self.api.get.return_value = self.make_api_result("char/wallet_info.xml")

        result, current, expires = self.char.wallet_info()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result,
            {
                'balance': 209127923.31,
                'id': 1,
                'key': 1000,
            }
        )
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/AccountBalance', params={'characterID': 1}),
            ])

    def test_wallet_balance(self):
        self.api.get.return_value = self.make_api_result("char/wallet_balance.xml")

        result, current, expires = self.char.wallet_balance()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, 209127923.31)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/AccountBalance', params={'characterID': 1}),
            ])

    @mock.patch('evelink.char.parse_wallet_transactions')
    def test_wallet_transcations(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_transactions

        result, current, expires = self.char.wallet_transactions()
        self.assertEqual(result, mock.sentinel.parsed_transactions)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletTransactions', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_wallet_transactions_paged(self):
        self.api.get.return_value = self.make_api_result("char/wallet_transactions.xml")

        self.char.wallet_transactions(before_id=1234)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletTransactions', params={'characterID': 1, 'fromID': 1234}),
            ])

    def test_wallet_transactions_limit(self):
        self.api.get.return_value = self.make_api_result("char/wallet_transactions.xml")

        self.char.wallet_transactions(limit=100)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/WalletTransactions', params={'characterID': 1, 'rowCount': 100}),
            ])

    @mock.patch('evelink.char.parse_industry_jobs')
    def test_industry_jobs(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.industry_jobs

        result, current, expires = self.char.industry_jobs()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.industry_jobs)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/IndustryJobs', params={'characterID': 1}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_industry_jobs')
    def test_industry_jobs_history(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.industry_jobs

        result, current, expires = self.char.industry_jobs_history()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.industry_jobs)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/IndustryJobsHistory', params={'characterID': 1}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_planetary_colonies')
    def test_planetary_colonies(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.planetary_colonies

        result, current, expires = self.char.planetary_colonies()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.planetary_colonies)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/PlanetaryColonies', params={'characterID': 1}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_planetary_links')
    def test_planetary_links(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.planetary_links

        result, current, expires = self.char.planetary_links(101)
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.planetary_links)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/PlanetaryLinks',
                              params={'characterID': 1,
                                      'planetID': 101}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_planetary_pins')
    def test_planetary_pins(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.planetary_pins

        result, current, expires = self.char.planetary_pins(101)
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.planetary_pins)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/PlanetaryPins',
                              params={'characterID': 1,
                                      'planetID': 101}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_planetary_routes')
    def test_planetary_routes(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.planetary_routes

        result, current, expires = self.char.planetary_routes(101)
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.planetary_routes)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/PlanetaryRoutes',
                              params={'characterID': 1,
                                      'planetID': 101}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    def test_planetary_routes_map(self):
        routes = {
            605707989: {'id': 605707989,
                        'source_id': 1014990361652,
                        'destination_id': 1014990361649,
                        'content': {'type': 2310, 'name': 'Noble Gas'},
                        'quantity': 3000,
                        'path': (1014990361647, 1014990361650, 0, 0, 0),
            },
            605707990: {'id': 605707990,
                        'source_id': 1014990361652,
                        'destination_id': 1014990361647,
                        'content': {'type': 2311, 'name': 'Reactive Gas'},
                        'quantity': 3000,
                        'path': (0, 0, 0, 0, 0),
            },
        }

        self.assertEqual(self.char.planetary_route_map(routes), {
            1014990361652: set([605707989, 605707990]),
            1014990361647: set([605707990]),
            1014990361649: set([605707989])}
        )

    @mock.patch('evelink.char.parse_kills')
    def test_kills(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.kills

        result, current, expires = self.char.kills()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.kills)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/KillMails', params={'characterID': 1}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    @mock.patch('evelink.char.parse_kills')
    def test_kill_log(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.kills

        result, current, expires = self.char.kill_log()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, mock.sentinel.kills)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/KillLog', params={'characterID': 1}),
            ])
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])

    def test_kills_paged(self):
        self.api.get.return_value = self.make_api_result("char/kills_paged.xml")

        self.char.kills(before_kill=12345)
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/KillMails', params={'characterID': 1, 'beforeKillID': 12345}),
            ])

    def test_character_sheet(self):
        self.api.get.return_value = self.make_api_result("char/character_sheet.xml")

        result, current, expires = self.char.character_sheet()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
            'id': 150337897,
            'name': 'corpslave',
            'create_ts': 1136073600,
            'race': 'Minmatar',
            'bloodline': 'Brutor',
            'ancestry': 'Slave Child',
            'gender': 'Female',
            'corp': {
                'id': 150337746,
                'name': 'corpexport Corp',
            },
            'alliance': {
                'id': None,
                'name': None
            },
            'balance': 190210393.87,
            'attributes': {
                'charisma': {'base': 7},
                'intelligence': {'base': 6},
                'memory': {'base': 4},
                'perception': {'base': 12},
                'willpower': {'base': 10},
            },
            'implants': {
                33516: 'High-grade Ascendancy Alpha',
                33525: 'High-grade Ascendancy Beta',
                33526: 'High-grade Ascendancy Delta',
                33527: 'High-grade Ascendancy Epsilon',
                33528: 'High-grade Ascendancy Gamma',
            },
            'skills': {
                3431: {'level': 3, 'published': True, 'skillpoints': 8000, 'id': 3431},
                3413: {'level': 3, 'published': True, 'skillpoints': 8000, 'id': 3413},
                21059: {'level': 1, 'published': True, 'skillpoints': 500, 'id': 21059},
                3416: {'level': 3, 'published': True, 'skillpoints': 8000, 'id': 3416},
                3445: {'level': 5, 'published': False, 'skillpoints': 512000, 'id': 3445}
            },
            'skillpoints': 536500,
            'roles': {
                'global': {1 : {'id': 1, 'name': 'roleDirector'}},
                'at_base': {1: {'id': 1, 'name': 'roleDirector'}},
                'at_hq': {1: {'id': 1, 'name': 'roleDirector'}},
                'at_other': {1: {'id': 1, 'name': 'roleDirector'}}
            },
            'titles': {1: {'id': 1, 'name': 'Member'}},
            'jump': {
                'activation_ts': 1414517621,
                'fatigue_ts': 1414517615,
                'last_update_ts': 1414507621,
            },
            'remote_station_ts': 1414507856,
            'last_respec_ts': 1402496116,
            'last_timed_respec_ts': 1399734757,
            'free_respecs': 2,
            'free_skillpoints': 50000,
            'home_station_id': 60011566,
            'jumpclone': {
                'clones': {
                    60014842: {
                        'id': 5,
                        'location_id': 60014842,
                        'name': '',
                        'type_id': 164,
                        'implants': {
                            22119: 'Mid-grade Slave Alpha',
                            22120: 'Mid-grade Slave Beta',
                            22121: 'Mid-grade Slave Delta',
                            22122: 'Mid-grade Slave Epsilon',
                            22123: 'Mid-grade Slave Gamma',
                            22124: 'Mid-grade Slave Omega',
                        },
                    },
                    60014848: {
                        'id': 4,
                        'location_id': 60014848,
                        'name': 'some random name',
                        'type_id': 164,
                        'implants': {
                            20499: 'High-grade Slave Alpha',
                            20501: 'High-grade Slave Beta',
                            20503: 'High-grade Slave Delta',
                            20505: 'High-grade Slave Epsilon',
                            20507: 'High-grade Slave Gamma',
                            20509: 'High-grade Slave Omega',
                            33068: 'QA SpaceAnchor Implant',
                        },
                    },
                    60014930: {
                        'id': 2,
                        'location_id': 60014930,
                        'name': '',
                        'type_id': 164,
                        'implants': {},
                    },
                },
                'jump_ts': 1412801690,
            },
        })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/CharacterSheet', params={'characterID': 1}),
            ])

    @mock.patch('evelink.char.parse_contact_list')
    def test_contacts(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_contacts

        result, current, expires = self.char.contacts()
        self.assertEqual(result, mock.sentinel.parsed_contacts)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/ContactList', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    @mock.patch('evelink.char.parse_market_orders')
    def test_orders(self, mock_parse):
        self.api.get.return_value = API_RESULT_SENTINEL
        mock_parse.return_value = mock.sentinel.parsed_orders

        result, current, expires = self.char.orders()
        self.assertEqual(result, mock.sentinel.parsed_orders)
        self.assertEqual(mock_parse.mock_calls, [
                mock.call(mock.sentinel.api_result),
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/MarketOrders', params={'characterID': 1}),
            ])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_notifications(self):
        self.api.get.return_value = self.make_api_result("char/notifications.xml")

        result, current, expires = self.char.notifications()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
            303795523: {'id': 303795523,
                        'read': True,
                        'sender_id': 671216635,
                        'timestamp': 1270836240,
                        'type_id': 16},
            304084087: {'id': 304084087,
                        'read': False,
                        'sender_id': 797400947,
                        'timestamp': 1271075520,
                        'type_id': 16}
            })

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Notifications', params={'characterID': 1}),
            ])

    def test_notification_texts(self):
        self.api.get.return_value = self.make_api_result("char/notification_texts.xml")

        result, current, expires = self.char.notification_texts(1234)
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
            374044083: {'shipTypeID': 606,
                        'id': 374044083,
                        'isHouseWarmingGift': 1},
            374067406: {'dueDate': 1336342200,
                        'amount': 25000000,
                        'id': 374067406},
            374106507: {'cost': None,
                        'declaredByID': 98105019,
                        'delayHours': None,
                        'hostileState': None,
                        'againstID': 673381830,
                        'id': 374106507},
            374119034: {'aggressorCorpID': 785714366,
                        'aggressorID': 1746208390,
                        'armorValue': 1.0,
                        'hullValue': 1.0,
                        'moonID': 40264916,
                        'shieldValue': 0.995,
                        'solarSystemID': 30004181,
                        'typeID': 16688,
                        'aggressorAllianceID': 673381830,
                        'id': 374119034},
            374133265: {'itemID': 1005888572647,
                        'payout': 1,
                        'amount': 5125528.4,
                        'id': 374133265}})

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/NotificationTexts', params={'characterID': 1, 'IDs': 1234}),
            ])

    def test_standings(self):
        self.api.get.return_value = self.make_api_result("char/standings.xml")

        result, current, expires = self.char.standings()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                'agents': {3009841: {'id': 3009841, 'name': 'Pausent Ansin', 'standing': 0.1},
                           3009846: {'id': 3009846, 'name': 'Charie Octienne', 'standing': 0.19}},
                'corps': {1000061: {'id': 1000061, 'name': 'Freedom Extension', 'standing': 0},
                          1000064: {'id': 1000064, 'name': 'Carthum Conglomerate', 'standing': 0.34},
                          1000094: {'id': 1000094, 'name': 'TransStellar Shipping', 'standing': 0.02}},
                'factions': {500003: {'id': 500003, 'name': 'Amarr Empire', 'standing': -0.1},
                             500020: {'id': 500020, 'name': 'Serpentis', 'standing': -1}}},
                )

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Standings', params={'characterID': 1}),
            ])

    def test_research(self):
        self.api.get.return_value = self.make_api_result("char/research.xml")

        result, current, expires = self.char.research()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
            3014201: {
                'id': 3014201,
                'per_day': 59.52,
                'remaining': -41461.92,
                'skill_id': 11445,
                'timestamp': 1178692470}
            })

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Research', params={'characterID': 1}),
            ])

    def test_current_training(self):
        self.api.get.return_value = self.make_api_result("char/current_training.xml")

        result, current, expires = self.char.current_training()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
            'current_ts': 1291690831,
            'end_sp': 2048000,
            'end_ts': 1295324413,
            'level': 5,
            'start_sp': 362039,
            'start_ts': 1291645953,
            'active': None,
            'type_id': 23950
            })

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/SkillInTraining', params={'characterID': 1}),
            ])

    def test_skill_queue(self):
        self.api.get.return_value = self.make_api_result("char/skill_queue.xml")

        result, current, expires = self.char.skill_queue()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, [
            {
                'end_ts': 1295324413,
                'level': 5,
                'type_id': 23950,
                'start_ts': 1291645953,
                'end_sp': 2048000,
                'start_sp': 362039,
                'position': 0},
            {
                'end_sp': 256000,
                'end_ts': 1342871633,
                'level': 5,
                'position': 1,
                'start_sp': 45255,
                'start_ts': 1342621219,
                'type_id': 3437},
            ])

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/SkillQueue', params={'characterID': 1}),
            ])

    def test_messages(self):
        self.api.get.return_value = self.make_api_result("char/messages.xml")

        result, current, expires = self.char.messages()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, [
                {
                    'id': 290285276,
                    'sender_id': 999999999,
                    'timestamp': 1259629440,
                    'title': 'Corp mail',
                    'to': {
                        'org_id': 999999999,
                        'char_ids': None,
                        'list_ids': None,
                    },
                },
                {
                    'id': 290285275,
                    'sender_id': 999999999,
                    'timestamp': 1259629440,
                    'title': 'Personal mail',
                    'to': {
                        'org_id': None,
                        'char_ids': [999999999],
                        'list_ids': None,
                    },
                },
                {
                    'id': 290285274,
                    'sender_id': 999999999,
                    'timestamp': 1259629440,
                    'title': 'Message to mailing list',
                    'to': {
                        'org_id': None,
                        'char_ids': None,
                        'list_ids': [999999999],
                    },
                },
            ])
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/MailMessages', params={'characterID': 1}),
            ])

    def test_message_bodies(self):
        self.api.get.return_value = self.make_api_result("char/message_bodies.xml")

        result, current, expires = self.char.message_bodies([297023723,297023208,297023210,297023211])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                297023208: '<p>Another message</p>',
                297023210: None,
                297023211: None,
                297023723: 'Hi.<br><br>This is a message.<br><br>',
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/MailBodies', params={
                    'characterID': 1,
                    'ids': [297023723,297023208,297023210,297023211],
                }),
            ])

    def test_mailing_lists(self):
        self.api.get.return_value = self.make_api_result("char/mailing_lists.xml")

        result, current, expires = self.char.mailing_lists()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                128250439: "EVETycoonMail",
                128783669: "EveMarketScanner",
                141157801: "Exploration Wormholes",
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/MailingLists', params={'characterID': 1}),
            ])

    def test_calendar_events(self):
        self.api.get.return_value = self.make_api_result("char/calendar_events.xml")

        result, current, expires = self.char.calendar_events()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                93264: {
                    'description': 'Join us for <a href="http://fanfest.eveonline.com/">     '
                                   'EVE Online\'s Fanfest 2011</a>!',
                    'duration': 0,
                    'id': 93264,
                    'important': False,
                    'owner': {
                        'id': 1,
                        'name': None,
                    },
                    'response': 'Undecided',
                    'start_ts': 1301130000,
                    'title': 'EVE Online Fanfest 2011',
                },
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/UpcomingCalendarEvents', params={
                    'characterID': 1,
                }),
            ])

    def test_calendar_attendees(self):
        self.api.get.return_value = self.make_api_result("char/calendar_attendees.xml")

        result, current, expires = self.char.calendar_attendees([123, 234, 345])
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                123: {
                    123456789: {
                        'id': 123456789,
                        'name': 'Jane Doe',
                        'response': 'Accepted',
                    },
                    987654321: {
                        'id': 987654321,
                        'name': 'John Doe',
                        'response': 'Tentative',
                    },
                },
                234: {
                    192837645: {
                        'id': 192837645,
                        'name': 'Another Doe',
                        'response': 'Declined',
                    },
                    918273465: {
                        'id': 918273465,
                        'name': 'Doe the Third',
                        'response': 'Undecided',
                    },
                },
                345: {},
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/CalendarEventAttendees', params={
                    'characterID': 1,
                    'eventIDs': [123, 234, 345],
                }),
            ])

    @mock.patch('evelink.char.Char.calendar_attendees')
    def test_event_attendees(self, mock_calendar):
        mock_calendar.return_value = evelink_api.APIResult(
            {42: mock.sentinel.attendees}, 12345, 67890)
        result, current, expires = self.char.event_attendees(42)
        self.assertEqual(result, mock.sentinel.attendees)
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_faction_warfare_stats(self):
        self.api.get.return_value = self.make_api_result("char/faction_warfare_stats.xml")

        result, current, expires = self.char.faction_warfare_stats()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                'enlist_ts': 1213135800,
                'faction': {'id': 500001, 'name': 'Caldari State'},
                'kills': {'total': 0, 'week': 0, 'yesterday': 0},
                'points': {'total': 0, 'week': 1044, 'yesterday': 0},
                'rank': {'current': 4, 'highest': 4},
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/FacWarStats', params={'characterID': 1}),
            ])

    def test_medals(self):
        self.api.get.return_value = self.make_api_result("char/medals.xml")

        result, current, expires = self.char.medals()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                'current': {},
                'other': {
                    4106: {
                        'corp_id': 1711141370,
                        'description': 'For taking initiative and...',
                        'id': 4106,
                        'issuer_id': 132533870,
                        'public': False,
                        'reason': 'For continued support, loyalty...',
                        'title': 'Medal of Service'}}
            })

        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Medals', params={
                    'characterID': 1
                }),
            ])

    def test_contact_notifications(self):
        self.api.get.return_value = self.make_api_result("char/contact_notifications.xml")

        result, current, expires = self.char.contact_notifications()
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

        self.assertEqual(result, {
                308734131: {
                    'data': {
                        'level': 10,
                        'message': 'Hi, I want to social network with you!',
                    },
                    'id': 308734131,
                    'sender': {
                        'id': 797400947,
                        'name': 'CCP Garthagk',
                    },
                    'timestamp': 1275174240,
                },
            })
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/ContactNotifications', params={'characterID': 1}),
            ])

    def test_locations(self):
        self.api.get.return_value = self.make_api_result("char/locations.xml")

        result, current, expires = self.char.locations((1009661446486, 1007448817800))
        self.assertEqual(self.api.mock_calls, [
                mock.call.get('char/Locations', params={'characterID': 1, 'IDs': (1009661446486, 1007448817800),}),
            ])
        self.assertEqual(result,
            {1009661446486:
                {
                    'id': 1009661446486,
                    'x': None,
                    'z': None,
                    'name': "Superawesome test Impairor",
                    'y': None,
                },
            1007448817800:
                {
                    'id': 1007448817800,
                    'x': -170714848271.291,
                    'z': 208419106396.3,
                    'name': "A Whale",
                    'y': -1728060949.58229,
                }
            }
        )
        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_blueprints(self):
        self.api.get.return_value = self.make_api_result("char/blueprints.xml")

        result, current, expires = self.char.blueprints()

        self.assertEqual(self.api.mock_calls, [mock.call.get('char/Blueprints', params={'characterID': 1}),])

        self.assertEqual(result, {
                1000000029372: {
                    'location_id': 60014929,
                    'type_id': 11568,
                    'type_name': 'Avatar Blueprint',
                    'location_flag': 4,
                    'quantity': 497,
                    'time_efficiency': 0,
                    'material_efficiency': 0,
                    'runs': -1,
                },
                1000000029377: {
                    'location_id': 60014929,
                    'type_id': 33876,
                    'type_name': 'Prophecy Blood Raiders Edition Blueprint',
                    'location_flag': 4,
                    'quantity': -2,
                    'time_efficiency': 0,
                    'material_efficiency': 0,
                    'runs': 20000,
                },
            })

        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

    def test_chat_channels(self):
        self.api.get.return_value = self.make_api_result("char/chat_channels.xml")

        result, current, expires = self.char.chat_channels()

        self.assertEqual(self.api.mock_calls,
            [mock.call.get('char/ChatChannels', params={'characterID': 1}),])

        self.maxDiff = None
        self.assertEqual(result, {
                -69329950: {
                    'id': -69329950,
                    'owner': {
                        'id': 95578451,
                        'name': 'CCP Tellus',
                    },
                    'name': 'Players\' Haven',
                    'comparison_name': 'players\'haven',
                    'passworded': False,
                    'motd': '<b>Feed pineapples to the cats!</b>',
                    'allowed': {
                        99005629: {
                            'id': 99005629,
                            'name': 'Tellus Alliance',
                        },
                    },
                    'blocked': {
                        98396389: {
                            'id': 98396389,
                            'name': 'Tellus Corporation',
                            'until_ts': None,
                            'reason': '',
                        },
                    },
                    'muted': {
                        90006031: {
                            'id': 90006031,
                            'name': 'CCP Nestor',
                            'until_ts': 1438960660,
                            'reason': 'Test success! You can\'t speak now.',
                        },
                    },
                    'ops': {
                        92168909: {
                            'id': 92168909,
                            'name': 'CCP FoxFour',
                        },
                        95465499: {
                            'id': 95465499,
                            'name': 'CCP Bartender',
                        },
                    },
                },
            })

        self.assertEqual(current, 12345)
        self.assertEqual(expires, 67890)

if __name__ == "__main__":
    unittest.main()


text:
package ca.ualberta.papaya.models;

import java.io.InvalidClassException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

import ca.ualberta.papaya.exceptions.BidNegativeException;
import ca.ualberta.papaya.exceptions.InvalidLocationException;
import ca.ualberta.papaya.exceptions.ThingUnavailableException;
import ca.ualberta.papaya.interfaces.IObserver;
import io.searchbox.annotations.JestId;

/**
 * Model class representing a Bid on a Thing owned by a User
 * @see ElasticModel
 *
 * Created by martin on 10/02/16.
 */
public class Bid extends ElasticModel {
    @JestId
    protected String id;

    @Override
    public String getId() {
        return id;
    }

    @Override
    public void setId(String newId) {
        id = newId;
    }

    public transient Class<?> kind;

    private String bidderName;       // Denormalized User.getName()
    private String bidderId;         // the bidder's .getId()
    private int amount;              // Amount of the bid (in cents)
    private Per per = Per.FLAT;      // Choice of rate plan. (flat rate, hourly, etc)
    private String thingId;          // the thing being bid on's .getId()
    private List<Number> location;   // Location [Longitude, Latitude]

    /**
     * Construct a new Bid on an item
     * @param thing the Thing being bid on
     * @param bidder the User performing making the Bid.
     * @param amount how much is being bid. (in cents)
     */
    public Bid(Thing thing, User bidder, int amount) throws ThingUnavailableException {
        super();
        kind = Bid.class;
        setAmount(amount);
        setThing(thing);
        setBidder(bidder);
    }

    /**
     * Construct a new Bid on an item at a time-based rate.
     * @param thing the Thing being bid on
     * @param bidder the User performing making the Bid.
     * @param amount how much is being bid. (in cents)
     * @param per the time per amount cost (hours, days, etc)
     */
    public Bid(Thing thing, User bidder, int amount, Per per) throws ThingUnavailableException {
        super();
        setThing(thing);
        setBidder(bidder);
        setAmount(amount);
        setPer(per);
    }

    public String getBidderName(){
        return this.bidderName;
    }
    public void getBidder(IObserver observer){
        User.getById(observer, User.class, bidderId);
    }
    public Bid setBidder(User bidder){
        this.bidderId = bidder.getId();
        this.bidderName = bidder.getFullName();
        changed();
        return this;
    }

    public String getBidderId() {
        return bidderId;
    }

    public void getThing(IObserver observer){
        Thing.getById(observer, Thing.class, thingId);
    }
    public Bid setThing(Thing thing) throws ThingUnavailableException {
        thingId = thing.getId();
        thing.placeBid(this);
        changed();
        return this;
    }

    public String getThingId() {
        return thingId;
    }

    public int getAmount(){ return amount; }
    public Bid setAmount(int amount) throws BidNegativeException {
        if(amount < 0){
            throw new BidNegativeException();
        }
        this.amount = amount;
        changed();
        return this;
    }

    public Per getPer(){ return per; }
    public Bid setPer(Per per) throws NullPointerException {
        if(per == null){
            throw new NullPointerException();
        }
        this.per = per;
        changed();
        return this;
    }

    public List getLocation(){ return location; }
    public Bid setLocation(List<Number> location){
        if (location.size() == 2){
            this.location = location;
        } else {
            throw new InvalidLocationException();
        }
        return this;
    }

    public String valueOf(){
        DecimalFormat formatter = new DecimalFormat("0.00");
        return formatter.format(((double)amount)/100);
    }

    public String toString(){
        return "$" + valueOf();
    }

    public enum Per {
        FLAT, HOUR, DAY, WEEK, MONTH;
        @Override public String toString() {
            return name().toLowerCase();
        }
    }

    protected void onDelete(){
        // no op
    }

}


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../../../">
  <title data-ice="title">DateType | formatron</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">

<meta name="description" content="A library that generates forms based on JSON schema."><meta property="twitter:card" content="summary"><meta property="twitter:title" content="formatron"><meta property="twitter:description" content="A library that generates forms based on JSON schema.">

  Home

  Reference
  Source

    <input class="search-input">

CImmutableListFilterRef

CImmutableListFindRef

CImmutableListMapRef

CImmutableListRef

CImmutableRef

CImmutableViewRef

CRef

FparseRef

FparseTemplate

FconvertDate

VFormatron

react/componentsCTetheredSelect

renderersCRenderers

CRenderData

CRenderer

VvalueRenderers

typesCType

FparseField

FregisterType

FregisterDataTypes

FregisterViewTypes

VDATA

VVIEW

Vdata

Vview

ToneOrManyParser

types/dataCBoolType

CDateType

CImmutableDictType

CEnumType

CDataType

CImmutableDataType

CImmutableListType

CImmutableListOrMapType

CImmutableMapType

CNumberType

CTextType

CValidationError

VvalidationErrors

types/viewCButtonType

CViewType

FcompareAll

FnumericalDisplay

FtextDisplay

FtruthyDisplay

types/view/dataCCalendarType

CCheckboxType

CCurrencyType

CDropDownType

CDataType

CLinkType

CNumberType

CPercentType

CTableType

CTextType

types/view/displayCGridType

CHeaderType

CDisplayType

CStaticType

CTabsType

types/view/valueCComputedType

CConditionType

CFunctionType

CValueType

CMethodType

CPropertyType

CSwitchType

CTemplateType

CVariableType

import DateType from 'formatron/src/types/data/date.js'

  public
  class

  | source

DateType

Extends:

Type → DataType → DateType

The DataType for date values. Stores a value of seconds since January 1st 1970.

Allowed options:

Name
Type
Attribute
Description

dateType
string

optional

default: 'datetime'

Whether to handle just a date, time or both. 'date' | 'time' | 'datetime'

Static Member Summary

Static Public Members

      public
      static

          typeName: *

Method Summary

Public Methods

      public

          convert(value: string | Date | moment | number, toType: string): string | moment | number

Converts between strings, JS Date objects, moment objects, or unix time values.

      public

          filter(filterValue: *, rowValue: *): *

this method was deprecated. Filtering will be refactored to its own module.

      public

          getDefaultFormat(): string

this method was deprecated. Will be moved to ViewType

      public

          getDisplay(value: *): *

this method was deprecated. Will be moved to view types.

      public

          getFormat(): *

this method was deprecated. Will be moved to ViewType

      public

          getType(): *

      public

          getValue(value: *): *

See DataType#getValue.

      public

          hasValue(value: any): boolean

Checks if the passed in value holds a valid date value.

Inherited Summary

 From class Type

      public
      static

          typeName: *

The type name.

      public
      static

          parse(field: object | Immutable.Map, parseField: function): Type

Parses a JS or Immutable.js object into a type.

      public
      static

          parseOneOrMany(parseField: func): oneOrManyParser

Creates a one or many parser with the passed in field parser.

      public
      static

          parseOptions(field: Immutable.Map, parseField: function): Immutable.Map

Override this function if you want the type to reference other types.

 From class DataType

      public
      static

          typeName: *

The data type name.

      public
      static

          parse(field: *, parseField: *): *

      public

          name: *

      public

          options: *

      public

          exclude(model: *, deep: boolean): *

      public

          filter(filterValue: *, rowValue: *): *

      public

          getDefaultValue(defaultValue: undefined): *

      public

          getDisplay(value: *): string

Returns the value parsed for human consumption.

      public

          getField(ref: *): *

      public

          getFieldAndValue(value: *, ref: *): {"field": *, "value": *}

      public

          getName(): *

      public

          getOptions(): *

      public

          getValidationLinks(): *

      public

          getValidator(): *

      public

          getValue(value: *, defaultValue: *): *

Returns a parsed value.

      public

          hasValue(value: object, checkDefault: boolean): boolean

Checks if the passed in value is "not empty".

      public

          isExcluded(): *

      public

          isGenerated(): *

      public

          isRequired(): *

      public

          isUnique(): *

      public

          validate(value: *, callback: *): *

Validates that the given value follows the rules of the data type.

Static Public Members

    public
    static

    typeName: *

      source

The data type name. This must be overridden.

Override:
DataType#typeName

Public Methods

    public

    convert(value: string | Date | moment | number, toType: string): string | moment | number

      source

Converts between strings, JS Date objects, moment objects, or unix time values.

Params:

Name	Type	Attribute	Description

      value
      string | Date | moment | number

The date value to convert

      toType
      string

optional

default: 'string'|'datetime'|'unix'

The type to convert to.

Return:

          string | moment | number

The date value in a new format.

    public

    filter(filterValue: *, rowValue: *): *

      source

this method was deprecated. Filtering will be refactored to its own module.

Override:
DataType#filter

Params:

Name	Type	Attribute	Description

      filterValue
      *

      rowValue
      *

Return:

          *

    public

    getDefaultFormat(): string

      source

this method was deprecated. Will be moved to ViewType

Return:

          string

    public

    getDisplay(value: *): *

      source

this method was deprecated. Will be moved to view types.

Returns the value parsed for human consumption.

Override:
DataType#getDisplay

Params:

Name	Type	Attribute	Description

      value
      *

Return:

          *

    public

    getFormat(): *

      source

this method was deprecated. Will be moved to ViewType

Return:

          *

    public

    getType(): *

      source

Return:

          *

<string> "date" | "time" | "datetime"

    public

    getValue(value: *): *

      source

See DataType#getValue.

Override:
DataType#getValue

Params:

Name	Type	Attribute	Description

      value
      *

Return:

          *

    public

    hasValue(value: any): boolean

      source

Checks if the passed in value holds a valid date value.

Override:
DataType#hasValue

Params:

Name	Type	Attribute	Description

      value
      any

The date value

Return:

          boolean

  Generated by ESDoc(1.1.0)


text:
"""RND agent."""

from acme.agents.jax.rnd.builder import RNDBuilder
from acme.agents.jax.rnd.config import RNDConfig
from acme.agents.jax.rnd.learning import rnd_loss
from acme.agents.jax.rnd.learning import rnd_update_step
from acme.agents.jax.rnd.learning import RNDLearner
from acme.agents.jax.rnd.learning import RNDTrainingState
from acme.agents.jax.rnd.networks import compute_rnd_reward
from acme.agents.jax.rnd.networks import make_networks
from acme.agents.jax.rnd.networks import rnd_reward_fn
from acme.agents.jax.rnd.networks import RNDNetworks