8000 land import syntax refactoring on 1.x branch · pythonindy/pythonnet@804cd51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 804cd51

Browse files
committed
land import syntax refactoring on 1.x branch
1 parent 7c42ea3 commit 804cd51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+586
-680
lines changed

pythonnet/demo/helloform.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
#
3-
# All Rights Reserved.
4-
#
1+
# ===========================================================================
52
# This software is subject to the provisions of the Zope Public License,
63
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
# FOR A PARTICULAR PURPOSE.
8+
# ===========================================================================
119

12-
import CLR.System.Windows.Forms as WinForms
13-
from CLR.System.Drawing import Size, Point
10+
import System.Windows.Forms as WinForms
11+
from System.Drawing import Size, Point
1412

1513

1614
class HelloApp(WinForms.Form):

pythonnet/demo/splitter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# Copyright (c) 2003 Zope Corporation and Contributors.
2-
#
3-
# All Rights Reserved.
4-
#
1+
# ===========================================================================
52
# This software is subject to the provisions of the Zope Public License,
63
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
# FOR A PARTICULAR PURPOSE.
8+
# ===========================================================================
119

12-
import CLR.System.Windows.Forms as WinForms
13-
from CLR.System.Drawing import Color, Size, Point
14-
from CLR import System
10+
import System.Windows.Forms as WinForms
11+
from System.Drawing import Color, Size, Point
12+
import System
1513

1614

1715
class Splitter(WinForms.Form):

pythonnet/demo/wordpad.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
# Copyright (c) 2003 Zope Corporation and Contributors.
2-
#
3-
# All Rights Reserved.
4-
#
1+
# ===========================================================================
52
# This software is subject to the provisions of the Zope Public License,
63
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
# FOR A PARTICULAR PURPOSE.
8+
# ===========================================================================
119

12-
import CLR.System.Windows.Forms as WinForms
13-
from CLR.System.Drawing import Color, Size, Point
14-
from CLR.System.Text import Encoding
15-
from CLR.System.IO import File
16-
from CLR import System
10+
import System.Windows.Forms as WinForms
11+
from System.Drawing import Color, Size, Point
12+
from System.Text import Encoding
13+
from System.IO import File
14+
import System
1715

1816

1917
class Wordpad(WinForms.Form):

pythonnet/src/console/assemblyinfo.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2004 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Reflection;
F438

pythonnet/src/console/pythonconsole.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using Python.Runtime;

pythonnet/src/runtime/arrayobject.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Collections;

pythonnet/src/runtime/assemblyinfo.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Reflection;

pythonnet/src/runtime/assemblymanager.cs

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.IO;
@@ -32,7 +30,6 @@ internal class AssemblyManager {
3230
static Hashtable namespaces;
3331
static ArrayList assemblies;
3432
static Hashtable probed;
35-
static int last;
3633

3734
private AssemblyManager() {}
3835

@@ -241,28 +238,33 @@ public static bool LoadImplicit(string name) {
241238

242239
static void ScanAssembly(Assembly assembly) {
243240

244-
// TODO: this is a workaround for a current Mono bug: calling
245-
// GetTypes on a generated assembly will cause it to fall over.
246-
// For now we'll skip generated assemblies, which usually are
247-
// uninteresting support code anyway.
248-
249-
if (assembly is AssemblyBuilder) {
250-
return;
251-
}
241+
// A couple of things we want to do here: first, we want to
242+
// gather a list of all of the namespaces contributed to by
243+
// the assembly. Since we have to rifle through all of the
244+
// types in the assembly anyway, we also build up a running
245+
// list of 'odd names' like generic names so that we can map
246+
// them appropriately later while still being lazy about
247+
// type lookup and instantiation.
252248

253249
Type[] types = assembly.GetTypes();
254250
for (int i = 0; i < types.Length; i++) {
255-
string type_ns = types[i].Namespace;
256-
if ((type_ns != null) && (!namespaces.ContainsKey(type_ns))) {
257-
string[] names = type_ns.Split('.');
251+
Type t = types[i];
252+
string ns = t.Namespace != null ? t.Namespace : "";
253+
if ((ns != null) && (!namespaces.ContainsKey(ns))) {
254+
string[] names = ns.Split('.');
258255
string s = "";
259256
for (int n = 0; n < names.Length; n++) {
260257
s = (n == 0) ? names[0] : s + "." + names[n];
261258
if (!namespaces.ContainsKey(s)) {
262-
namespaces.Add(s, String.Empty);
259+
namespaces.Add(s, new Hashtable());
263260
}
264261
}
265262
}
263+
264+
Hashtable asm = namespaces[ns] as Hashtable;
265+
if (ns != null && !asm.ContainsKey(assembly)) {
266+
asm.Add(assembly, String.Empty);
267+
}
266268
}
267269
}
268270

@@ -277,6 +279,38 @@ public static bool IsValidNamespace(string name) {
277279
}
278280

279281

282+
//===================================================================
283+
// Returns the current list of valid names for the input namespace.
284+
//===================================================================
285+
286+
public static StringCollection GetNames(string nsname) {
287+
StringCollection names = new StringCollection();
288+
if (namespaces.ContainsKey(nsname)) {
289+
Hashtable asm = namespaces[nsname] as Hashtable;
290+
foreach (Object o in asm.Keys) {
291+
Assembly a = o as Assembly;
292+
Type[] types = a.GetTypes();
293+
for (int i = 0; i < types.Length; i++) {
294+
Type t = types[i];
295+
if (t.Namespace == nsname) {
296+
names.Add(t.Name);
297+
}
298+
}
299+
}
300+
int nslen = nsname.Length;
301+
foreach (object n in namespaces.Keys) {
302+
string key = n as string;
303+
if (key.Length > nslen && key.StartsWith(nsname)) {
304+
string tail = key.Substring(nslen);
305+
if (key.IndexOf('.') == -1) {
306+
names.Add(key);
307+
}
308+
}
309+
}
310+
}
311+
return names;
312+
}
313+
280314
//===================================================================
281315
// Returns the System.Type object for a given qualified name,
282316
// looking in the currently loaded assemblies for the named

pythonnet/src/runtime/classbase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Collections;

pythonnet/src/runtime/classmanager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Runtime.InteropServices;

pythonnet/src/runtime/classobject.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2003 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Reflection;

pythonnet/src/runtime/clrobject.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Collections;

pythonnet/src/runtime/codegenerator.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Threading;

pythonnet/src/runtime/constructorbinder.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2003 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Reflection;

pythonnet/src/runtime/converter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Reflection;

pythonnet/src/runtime/debughelper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Collections;

pythonnet/src/runtime/delegatemanager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// Copyright (c) 2001, 2002 Zope Corporation and Contributors.
2-
//
3-
// All Rights Reserved.
4-
//
1+
// ==========================================================================
52
// This software is subject to the provisions of the Zope Public License,
63
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
74
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
85
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
107
// FOR A PARTICULAR PURPOSE.
8+
// ==========================================================================
119

1210
using System;
1311
using System.Threading;

0 commit comments

Comments
 (0)
0