Why aren't firstResult and maxResult working in withCriteria? - mongodb

I'm getting the following error:
Class
groovy.lang.MissingMethodException
Message
No signature of method: com.apposit.terra.connect.service.OrganizationUserService.firstResult() is applicable for argument types: (java.lang.Long) values: [2] Possible solutions: findResult(groovy.lang.Closure), findResult(java.lang.Object, groovy.lang.Closure)
Around line 35 of grails-app/services/com/apposit/terra/connect/service/OrganizationUserService.groovy
32: if(null != organization)
33: return User.withCriteria { eq( "organization" , organization)
34: eq( "accountExpired" , false )
35: firstResult( offset )
36: maxResults( max )
37:
38: }
I'm using mongodb.

Related

Set AudioWorkletProcessor input to Float32Array

I have been trying to extract input from one AudioWorkletProcessor using postMessage, then insert that input into another AudioWorkletProcessor.
I managed to get the Float32Array into the second AudioWorkletProcessor process method but RingBuffer doesn't seem to work.
I don't know how to detect errors inside the process method or any error related to RingBuffer.
I get silence output, no errors in the console.
I need to know how can I pass the extracted Float32Array to ring-buffer-worklet-processor output.
Thank you in advance.
EDIT: After I added ( outputChannelCount: [2] ) to ringBufferWorkletNode options I started to get audio in the output but not clear at all.
const ringBufferWorkletNode = new AudioWorkletNode(
audioCtx,
"ring-buffer-worklet-processor",
{
outputChannelCount: [2],
processorOptions: {
kernelBufferSize: audioCtx.sampleRate,
channelCount: 2,
},
}
);
Main thread:
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(async (stream) => {
const source = audioCtx.createMediaStreamSource(stream);
await audioCtx.audioWorklet.addModule("http://localhost:3003/lib/audio-processor.js");
await audioCtx.audioWorklet.addModule("http://localhost:3003/lib/ring-buffer-worklet-
processor.js");
const voiceNode = new AudioWorkletNode(audioCtx, "audio-processor");
const ringBufferWorkletNode = new AudioWorkletNode(audioCtx, "ring-buffer-worklet-processor",{
// EDIT: added outputChannelCount
outputChannelCount: [2],
processorOptions: {
kernelBufferSize: audioCtx.sampleRate / 2, // 48000/2
channelCount: 2,
},
}
);
voiceNode.port.onmessage = (e) => {
ringBufferWorkletNode.port.postMessage(e.data);
};
ringBufferWorkletNode.port.onmessage = (e) => {
console.log(e.data);
};
source.connect(voiceNode);
ringBufferWorkletNode.connect(audioCtx.destination);
}
audio-processor.js
class AudioProcessor extends AudioWorkletProcessor {
constructor(...args) {
super(...args);
}
process(inputList, outputList, parameters) {
this.port.postMessage(inputList[0]);
return true;
}
}
registerProcessor("audio-processor", AudioProcessor);
ring-buffer-worklet-processor.js
import Module from "./variable-buffer-kernel.wasmmodule.js";
import { HeapAudioBuffer, RingBuffer } from "./wasm-audio-helper.js";
class RingBufferWorkletProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [
{
name: "input",
defaultValue: null,
},
];
}
constructor(options) {
super();
this._kernelBufferSize = options.processorOptions.kernelBufferSize;
this._channelCount = options.processorOptions.channelCount;
// RingBuffers for input and output.
this._inputRingBuffer = new RingBuffer(
this._kernelBufferSize,
this._channelCount
);
this._outputRingBuffer = new RingBuffer(
this._kernelBufferSize,
this._channelCount
);
// For WASM memory, also for input and output.
this._heapInputBuffer = new HeapAudioBuffer(
Module,
this._kernelBufferSize,
this._channelCount
);
this._heapOutputBuffer = new HeapAudioBuffer(
Module,
this._kernelBufferSize,
this._channelCount
);
// WASM audio processing kernel.
this._kernel = new Module.VariableBufferKernel(this._kernelBufferSize);
this.inputData = null;
this.port.onmessage = this.onmessage.bind(this);
}
onmessage = (e) => {
const { data } = e;
if (data) {
this.inputData = data;
} else {
this.inputData = null;
}
};
process(inputs, outputs, parameters) {
let output = outputs[0];
let input = this.inputData;
// AudioWorkletProcessor always gets 128 frames in and 128 frames out. Here
// we push 128 frames into the ring buffer.
if (input) {
this.port.postMessage(input);
// I get : (2) [Float32Array(128), Float32Array(128)] in console full with numbers not 0s
this._inputRingBuffer.push(input);
// Process only if we have enough frames for the kernel.
if (this._inputRingBuffer.framesAvailable >= this._kernelBufferSize) {
// Get the queued data from the input ring buffer.
this._inputRingBuffer.pull(this._heapInputBuffer.getChannelData());
// This WASM process function can be replaced with ScriptProcessor's
// |onaudioprocess| callback funciton. However, if the event handler
// touches DOM in the main scope, it needs to be translated with the
// async messaging via MessagePort.
this._kernel.process(
this._heapInputBuffer.getHeapAddress(),
this._heapOutputBuffer.getHeapAddress(),
this._channelCount
);
// Fill the output ring buffer with the processed data.
this._outputRingBuffer.push(this._heapOutputBuffer.getChannelData());
}
// Always pull 128 frames out. If the ring buffer does not have enough
// frames, the output will be silent.
this._outputRingBuffer.pull(output);
}
return true;
}
}
registerProcessor("ring-buffer-worklet-processor", RingBufferWorkletProcessor);
console.log sample coming from main thread:
ringBufferWorkletNode.port.onmessage = (e) => {
console.log(e.data);
};
(2) [Float32Array(128), Float32Array(128)]
0: Float32Array(128)
[0 … 99]
0: -0.00013565909466706216
1: -0.00004953467214363627
2: -0.00008576592517783865
3: -0.00005288537431624718
4: -0.000025271740014431998
5: -0.000051156635890947655
6: -0.00003429186836001463
7: -0.000021470399587997235
8: -0.000034319222322665155
9: -0.0000439783361798618
10: -0.000009586839041730855
11: -0.00003202698644599877
12: 0.000033984630135819316
13: -0.00002201009374402929
14: -0.00007097060733940452
15: 0.000004624932444130536
16: -0.00009633887384552509
17: 0.00000770429596741451
18: -0.00004159680975135416
19: -0.00012190178676974028
20: -0.00001845001861511264
21: -0.00008007502037798986
22: -0.00004237010216456838
23: -0.00001076792977983132
24: -0.00006972716801101342
25: -0.0000477194698760286
26: -0.000021934287360636517
27: -0.00009244760440196842
28: -0.000007403687050100416
29: 0.000007816993274900597
30: -0.00008117098332149908
31: -0.00003129038304905407
32: 0.00009489256626693532
33: 0.000023729033273411915
34: -0.000009693003448774107
35: -0.00003678350549307652
36: -0.00011439441732363775
37: -0.00003462867607595399
38: 0.000029057020583422855
39: -0.00003098553133895621
40: -0.00004036649261252023
41: -0.00001566937135066837
42: -0.00003948688390664756
43: -0.000021292273231665604
44: -0.000031062725611263886
45: -0.00006067131835152395
46: -0.00008801861258689314
47: -0.0000940829049795866
48: -0.000027806054276879877
49: 0.000005677926765201846
50: -0.00004410342808114365
51: -0.00005494384822668508
52: -0.00012077790597686544
53: -0.00005381474693422206
54: -0.00004889833144261502
55: -0.00006171152199385688
56: -0.00007169923628680408
57: -0.000027956590201938525
58: -0.0000925964122870937
59: -0.00008822995005175471
60: -0.00011014055053237826
61: -0.00009332459740107879
62: -0.00007393134728772566
63: -0.00009183597285300493
64: -0.000051114031521137804
65: -0.00009899734141072258
66: -0.00001619849535927642
67: -0.00006849400961073115
68: -0.00007494576129829511
69: -0.00004512929081101902
70: -0.00007846889639040455
71: -0.0000887925925781019
72: -0.00011394681496312842
73: -0.0000661616213619709
74: -0.00006388152542058378
75: -0.000028652870241785422
76: -0.000049569716793484986
77: -0.000008633718607597984
78: -0.00003698172440635972
79: -0.00007338733121287078
80: -0.00004050061761518009
81: -0.00011863364488817751
82: -0.00005003352271160111
83: 0.00009503970795776695
84: -0.000020715609934995882
85: -0.000040291022742167115
86: -0.00006244835822144523
87: -0.00013285929162520915
88: -0.00009266978304367512
89: -0.00015499485016334802
90: 0.000009959074304788373
91: -0.00002722918361541815
92: -0.000045168246288085356
93: 0.00005641198004013859
94: -6.97990401477e-7
95: -0.00008256734145106748
96: -0.00011380571231711656
97: -0.00010966734407702461
98: -0.00010636053775670007
99: -0.00009042541933013126
[100 … 127]
buffer:
ArrayBuffer(512)
byteLength: 512
byteOffset: 0
length: 128
Symbol(Symbol.toStringTag): (...)
[[Prototype]]: TypedArray
1: Float32Array(128)
[0 … 99]
[100 … 127]
buffer:
ArrayBuffer(512)
byteLength: 512
byteOffset: 0
length: 128
Symbol(Symbol.toStringTag): (...)
[[Prototype]]: TypedArray
length: 2
[[Prototype]]: Array(0)
This is the GitHub I was following: https://github.com/GoogleChromeLabs/web-audio-samples/tree/main/audio-worklet/design-pattern/wasm-ring-buffer

i am getting error while using window functions in pyspark

i am trying to run the below code
employees = (spark.read.format('csv')
.option('sep', '\t')
.schema('''EMP_ID INT,F_NAME STRING,L_NAME STRING,
EMAIL STRING,PHONE_NR STRING,HIRE_DATE STRING,
JOB_ID STRING,SALARY FLOAT,
COMMISSION_PCT STRING,
MANAGER_ID STRING,DEP_ID STRING''')
.load('C:/data/hr_db/employees')
)
spec = Window.partitionBy('DEP_ID')
emp = (employees
.select('JOB_ID', 'DEP_ID', 'SALARY')
.withColumn('Total Salary', sum('SALARY').over(spec))
.orderBy('DEP_ID')
)
emp.show()
and getting the below error
File "C:\spark-2.4.4-bin-hadoop2.7\python\lib\py4j-0.10.7-src.zip\py4j\protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o60.showString.java.lang.IllegalArgumentException: Unsupported class file major version 56
could you please anyone help me on this error?

Freeradius 3.0.20 replay rlm_rest response

I try to reply a rest response to the user as a simple string (reply message). The authentication against an rest api works and i get a json formatted reponse (called "token"). I've declared this attribute as an attribute in raddb/dictionary file.
My question is: How can i access this attribute in authentication or post-authentication section?
Below my config (raddb/sites-available/default):
authenticate {
#
# REST authentication
Auth-Type rest {
rest {
updated = 1
}
if (updated) {
%{Token}
ok
}
}
I tried all possibilities like &Token "%{Token}" &rest:Token
See below my Debug-Output:
Ready to process requests,
(0) Received Access-Request Id 96 from 127.0.0.1:49260 to 127.0.0.1:1812 length 50,
(0) User-Name = "Arya Stark",
(0) User-Password = "verySecret",
(0) # Executing section authorize from file /etc/freeradius/sites-enabled/default,
(0) authorize {,
(0) [preprocess] = ok,
(0) [chap] = noop,
(0) [mschap] = noop,
(0) [digest] = noop,
(0) suffix: Checking for suffix after "#",
(0) suffix: No '#' in User-Name = "Arya Stark", looking up realm NULL,
(0) suffix: No such realm "NULL",
(0) [suffix] = noop,
(0) eap: No EAP-Message, not doing EAP,
(0) [eap] = noop,
(0) files: users: Matched entry DEFAULT at line 154,
(0) [files] = ok,
(0) [expiration] = noop,
[logintime] = noop,
Not doing PAP as Auth-Type is already set.,
(0) [pap] = noop,
(0) } # authorize = ok,
Found Auth-Type = rest,
(0) # Executing group from file /etc/freeradius/sites-enabled/default,
(0) Auth-Type rest {,
rlm_rest (rest): Reserved connection (0),
(0) rest: Expanding URI components,
(0) rest: EXPAND https://172.16.0.5,
(0) rest: --> https://172.16.0.5,
(0) rest: EXPAND /identityprovider/auth/passwordlogin,
(0) rest: --> /identityprovider/auth/passwordlogin,
(0) rest: Sending HTTP POST to "https://172.16.0.5/provider/auth/login",
(0) rest: EXPAND { "Username": "%{User-Name}", "Password":"%{User-Password}" },
(0) rest: --> { "Username": "Arya Stark", "Password":"verySecret" },
(0) rest: Processing response header,
(0) rest: Status : 200 (OK),
(0) rest: Type : json (application/json),
(0) rest: Parsing attribute "token",
(0) rest: EXPAND eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBcnlhIFN0YXJrIiwiaWF0IjoxNTgwMTI5......1DuIVMzCI4a1UWUThAce0xnA,
(0) rest: --> eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBcnlhIFN0YXJrIiwiaWF0IjoxNTgwMTI5......1DuIVMzCI4a1UWUThAce0xnA,
(0) rest: Token := "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBcnlhIFN0YXJrIiwiaWF0IjoxNTgwMTI5......1DuIVMzCI4a1UWUThAce0xnA",
rlm_rest (rest): Released connection (0),
Need 5 more connections to reach 10 spares,
rlm_rest (rest): Opening additional connection (5), 1 of 27 pending slots used,
rlm_rest (rest): Connecting to "https://172.16.0.5",
(0) [rest] = updated,
(0) if (updated) {,
(0) if (updated) -> TRUE,
(0) if (updated) {,
(0) EXPAND %{Token},
(0) --> ,
(0) [ok] = ok,
(0) } # if (updated) = ok,
(0) } # Auth-Type rest = ok,
(0) # Executing section post-auth from file /etc/freeradius/sites-enabled/default,
(0) post-auth {,
(0) if (session-state:User-Name && reply:User-Name && request:User-Name && (reply:User-Name == request:User-Name)) {,
(0) if (session-state:User-Name && reply:User-Name && request:User-Name && (reply:User-Name == request:User-Name)) -> FALSE,
(0) update {,
(0) No attributes updated for RHS &session-state:,
(0) } # update = noop,
(0) [exec] = noop,
(0) policy remove_reply_message_if_eap {,
(0) if (&reply:EAP-Message && &reply:Reply-Message) {,
(0) if (&reply:EAP-Message && &reply:Reply-Message) -> FALSE,
(0) else {,
(0) [noop] = noop,
(0) } # else = noop,
(0) } # policy remove_reply_message_if_eap = noop,
} # post-auth = noop,
(0) Sent Access-Accept Id 96 from 127.0.0.1:1812 to 127.0.0.1:49260 length 0,
(0) Finished request,
Waking up in 4.9 seconds.,
(0) Cleaning up request packet ID 96 with timestamp +17,
Ready to process requests,
The issue here is that by default any attributes specified in the JSON response are inserted into the reply list.
This can be fixed in two ways, either change your JSON blob to specify a list qualifier:
{ 'request:Token': '<token value>' }
or access the attribute in the reply list:
%{reply:Token}

Failing Rails 4 controller test - ActiveRecord::AssociationTypeMismatch?

I'm building a Rails (4.1.8) application with Postgres (0.18.3), Rspec (3.1.0), and FactoryGirl (4.5.0). I need help troubleshooting a controller test, which is throwing an Active Record::AssociationTypeMismatch error caused by a FactoryGirl object.
Here's my Fitness goals controller index action:
def index
#fitness_goals = #member.fitness_goals.order(:start_date)
end
This is my set-up and test of the fitness goals controller index action (fitness_goals_controller_spec.rb):
RSpec.describe FitnessGoalsController, :type => :controller do
let(:member_attributes) { {
"first_name" => 'Joe',
"last_name" => 'Smith',
"sex" => 'Male',
"age" => 30,
"height" => 69,
"weight" => 187,
"goal" => ["Lose Fat"],
"start_date" => Date.current
}
}
before :each do
#request.env["devise.mapping"] = Devise.mappings[:user]
#user = FactoryGirl.create(:user)
sign_in #user
#member = #user.build_member member_attributes
#member.save
#fitness_goal = FactoryGirl.create(:fitness_goal, member: #member)
#fitness_goal_attributes = FactoryGirl.build(:fitness_goal).attributes
#fitness_goal_invalid_attributes = FactoryGirl.build(:fitness_goal, timeframe_id: nil).attributes
#fitness_goal_update_attributes = FactoryGirl.build(:fitness_goal).attributes
#fitness_goal_update_invalid_attributes = FactoryGirl.build(:fitness_goal, timeframe_id: nil).attributes
end
describe "GET index" do
it "assigns all fitness goals as #member.fitness_goals" do
get :index, { :member_id => #member }
expect(assigns(:fitness_goals)).to eq(#member.reload.fitness_goals)
end
end
The rspec error and backtrace:
1) FitnessGoalsController GET index assigns all fitness goals as #member.fitness_goals
Failure/Error: #fitness_goal = FactoryGirl.create(:fitness_goal, member: #member)
ActiveRecord::AssociationTypeMismatch:
Target(#62887900) expected, got String(#8489780)
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/association.rb:216:in `raise_on_type_mismatch!'
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/collection_association.rb:356:in `block in replace'
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/collection_association.rb:356:in `each'
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/collection_association.rb:356:in `replace'
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/collection_association.rb:41:in `writer'
# .rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/associations/builder/association.rb:118:in `targets='
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:16:in `public_send'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:12:in `object'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `result'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in `run'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# .rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/notifications.rb:161:in `instrument'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in `run'
# .rvm/gems/ruby-2.1.5/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/controllers/fitness_goals_controller_spec.rb:44:in `block (2 levels) in <top (required)>'
The error references the Target model, a has_and_belongs_to_many (HABTM) association with the Fitness Goal model:
Target(#62887900) expected, got String(#8489780)
The relevant models:
class FitnessGoal < ActiveRecord::Base
has_and_belongs_to_many :targets
end
class Target < ActiveRecord::Base
has_and_belongs_to_many :fitness_goals
end
The join table in schema:
create_table "fitness_goals_targets", id: false, force: true do |t|
t.integer "fitness_goal_id"
t.integer "target_id"
end
Fitness goal params:
def fitness_goal_params
params.require(:fitness_goal).permit(:goal_list_id, :timeframe_id, :start_date, :end_date, { target_ids: [] }, { activity_ids: [] }, :notes, :member_id, :trainer_id)
end
Fitness Goal factory:
FactoryGirl.define do
factory :fitness_goal do
association :goal_list
association :timeframe
start_date Date.current
end_date Date.current + 30
targets ["Lose Fat", "Reduce caloric intake by x%"]
activities ["Walk x steps a day", "Climb x floors a day", "Run x miles a day"]
association :member
association :trainer
notes 'This is a sample note.'
end
end
What am I doing wrong? The application code works as expected in both development and production environments. It appears the problem is somewhere in my set-up for the FactoryGirl object. Implementing the HABTM association is what broke the controller test. How do I fix the issue and get the controller test passing again? Thanks for any help!
You need to change your factory to pass in Target objects rather than strings to that association. So you need to create Target objects (or find them, if they already exist). Change
targets ["Lose Fat", "Reduce caloric intake by x%"]
to
targets { [create(:target, field: "Lose Fat"), create(:target, field: "Reduce caloric intake by x%")] }
The label I used is 'field' because I'm not sure what that field is named, so just use its name instead.

Is there a unicodedata module for IronPython?

I'm trying to get the generic sample code for the selenium2 Sauce OnDemand service working with IronPython, for some test work I'm doing, and I've run into a problem I can't quite figure out.
First, Here's the environment:
Windows 7 Home Premium, 64bit.
IronPython 2.7.0.40 on .Net 4.0.30319.225
My path:
>>> sys.path
['.', 'C:\\users\\me\\scripts\\python', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\Lib', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\DLLs', 'C:\\opt\\win\\ipy\\Lib', 'C:\\opt\\win\\ipy\\DLLs', 'C:\\opt\\win\\ipy']
I'm aware that IronPython has issues using compressed eggs, so I've extracted the following libraries into the \Lib directory on the sys.path:
selenium (2.0b4dev)
rdflib (3.1.0)
Now, the sample code from Sauce Labs:
import unittest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = dict(platform="WINDOWS",
browserName="firefox",
version="3.6",
name="Hello, Selenium 2!")
self.driver = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://me:my-site-access-key#ondemand.saucelabs.com:80/wd/hub")
def test_sauce(self):
self.driver.get('http://example.saucelabs.com')
assert "Sauce Labs" in self.driver.title
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
Here's the error I'm getting:
Traceback (most recent call last):
File "selenium2_test.py", line 3, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\__init__.py", line 18, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\webdriver.py", line 24, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\firefox_profile.py", line 23, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\__init__.py", line 65, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\namespace.py", line 282, in <module>
ImportError: No module named unicodedata
I've tried searching for packages with unicodedata in them (such as FePY), but none of them seem to work. I've tried copying the .pyd from my Python27 installation, but that didn't work either.
Is this something that's not yet available in IronPython 2.7? Alternatively, is there a library or namespace I can reference to accomplish the same task?
If not, I guess I'll have to go without selenium2 until the Iron guys get a unicodedata for IP27. :(
Thanks,
Greg.
Alas, the unicodedata module is currently not included in IronPython. But fear not! For the upcoming 2.7.1 release will have it, and all of your troubles shall be no more.
Sorry about that. As for when 2.7.1 will be released, I'm thinking early June. You can check https://github.com/IronLanguages/main/commit/5395af28b5794b0acf982ab87d17466925ab819f for the patch, but it's fairly large and fiddly because of the included Unicode database.
See #Micheal Greene's comments on the original question. Here is the module with the edits as directed:
# Copyright (c) 2006 by Seo Sanghyeon
# 2006-07-13 sanxiyn Created
# 2006-07-19 sanxiyn Added unidata_version, normalize
# Modified 2011 - Greg Gauthier - To provide needed functionality for rdflib
# and other utilities, in IronPython 2.7.0
unidata_version = '3.2.0'
# --------------------------------------------------------------------
# Normalization
from System import String
from System.Text import NormalizationForm
def normalize(form, string):
return String.Normalize(string, _form_mapping[form])
_form_mapping = {
'NFC': NormalizationForm.FormC,
'NFKC': NormalizationForm.FormKC,
'NFD': NormalizationForm.FormD,
'NFKD': NormalizationForm.FormKD,
}
# --------------------------------------------------------------------
# Character properties
from System.Globalization import CharUnicodeInfo
def _handle_default(function):
def wrapper(unichr, default=None):
result = function(unichr)
if result != -1:
return result
if default is None:
raise ValueError()
return default
return wrapper
decimal = _handle_default(CharUnicodeInfo.GetDecimalDigitValue)
digit = _handle_default(CharUnicodeInfo.GetDigitValue)
numeric = _handle_default(CharUnicodeInfo.GetNumericValue)
def category(unichr):
uc = CharUnicodeInfo.GetUnicodeCategory(unichr)
return _category_mapping[int(uc)]
_category_mapping = {
0: 'Lu',
1: 'Ll',
2: 'Lt',
3: 'Lm',
4: 'Lo',
5: 'Mn',
6: 'Mc',
7: 'Me',
8: 'Nd',
9: 'Nl',
10: 'No',
11: 'Zs',
12: 'Zl',
13: 'Zp',
14: 'Cc',
15: 'Cf',
16: 'Cs',
17: 'Co',
18: 'Pc',
19: 'Pd',
20: 'Ps',
21: 'Pe',
22: 'Pi',
23: 'Pf',
24: 'Po',
25: 'Sm',
26: 'Sc',
27: 'Sk',
28: 'So',
29: 'Cn',
}
# added for rdflib/ironpython
def decomposition(unichr):
return String.Normalize(unichr.ToString(), NormalizationForm.FormD)