| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,6 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | import clr | |
| 2 | 5 | ||
| 3 | 6 | SWF = clr.AddReference("System.Windows.Forms") | |
@@ -13,7 +16,7 @@ class HelloApp(WinForms.Form): | |||
| 13 | 16 | def __init__(self): | |
| 14 | 17 | self.Text = "Hello World From Python" | |
| 15 | 18 | self.AutoScaleBaseSize = Size(5, 13) | |
| 16 | - self.ClientSize = Size(392, 117); | ||
| 19 | + self.ClientSize = Size(392, 117) | ||
| 17 | 20 | h = WinForms.SystemInformation.CaptionHeight | |
| 18 | 21 | self.MinimumSize = Size(392, (117 + h)) | |
| 19 | 22 | ||
@@ -36,8 +39,8 @@ def __init__(self): | |||
| 36 | 39 | ||
| 37 | 40 | # Add the controls to the form | |
| 38 | 41 | self.AcceptButton = self.button | |
| 39 | - self.Controls.Add(self.button); | ||
| 40 | - self.Controls.Add(self.textbox); | ||
| 42 | + self.Controls.Add(self.button) | ||
| 43 | + self.Controls.Add(self.textbox) | ||
| 41 | 44 | ||
| 42 | 45 | def button_Click(self, sender, args): | |
| 43 | 46 | """Button click event handler""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,12 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | import clr | |
| 5 | + | ||
| 6 | + import System | ||
| 2 | 7 | import System.Windows.Forms as WinForms | |
| 8 | + | ||
| 3 | 9 | from System.Drawing import Color, Size, Point | |
| 4 | - import System | ||
| 5 | 10 | ||
| 6 | 11 | ||
| 7 | 12 | class Splitter(WinForms.Form): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,14 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | import clr | |
| 5 | + import System | ||
| 2 | 6 | import System.Windows.Forms as WinForms | |
| 3 | - from System.Threading import Thread, ThreadStart, ApartmentState | ||
| 4 | - from System.Drawing import Color, Size, Point | ||
| 5 | - from System.Text import Encoding | ||
| 7 | + | ||
| 6 | 8 | from System.IO import File | |
| 7 | - import System | ||
| 9 | + from System.Text import Encoding | ||
| 10 | + from System.Drawing import Color, Point, Size | ||
| 11 | + from System.Threading import ApartmentState, Thread, ThreadStart | ||
| 8 | 12 | ||
| 9 | 13 | ||
| 10 | 14 | class Wordpad(WinForms.Form): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,11 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | """ | |
| 2 | 5 | Setup script for building clr.pyd and dependencies using mono and into | |
| 3 | 6 | an egg or wheel. | |
| 4 | 7 | """ | |
| 8 | + | ||
| 5 | 9 | from setuptools import setup, Extension | |
| 6 | 10 | from distutils.command.build_ext import build_ext | |
| 7 | 11 | from distutils.command.install_lib import install_lib | |
@@ -23,7 +27,7 @@ | |||
| 23 | 27 | ||
| 24 | 28 | ||
| 25 | 29 | def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False): | |
| 26 | - """Return full path to one of the microsoft build tools""" | ||
| 30 | + """Return full path to one of the Microsoft build tools""" | ||
| 27 | 31 | path = find_executable(tool) | |
| 28 | 32 | if path: | |
| 29 | 33 | return path | |
@@ -82,7 +86,8 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False): | |||
| 82 | 86 | finally: | |
| 83 | 87 | hreg.Close() | |
| 84 | 88 | ||
| 85 | - # Add Visual C++ for Python as a fallback in case one of the other Windows SDKs isn't installed | ||
| 89 | + # Add Visual C++ for Python as a fall-back in case one | ||
| 90 | + # of the other Windows SDKs isn't installed | ||
| 86 | 91 | if use_windows_sdk: | |
| 87 | 92 | localappdata = os.environ["LOCALAPPDATA"] | |
| 88 | 93 | pywinsdk = localappdata + r"\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Bin" | |
@@ -110,14 +115,13 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False): | |||
| 110 | 115 | _config = "%sMono" % CONFIG | |
| 111 | 116 | ||
| 112 | 117 | else: | |
| 113 | - raise NotImplementedError("DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS) | ||
| 118 | + raise NotImplementedError( | ||
| 119 | + "DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS) | ||
| 114 | 120 | ||
| 115 | 121 | ||
| 116 | 122 | class PythonNET_BuildExt(build_ext): | |
| 117 | 123 | def build_extension(self, ext): | |
| 118 | - """ | ||
| 119 | - Builds the .pyd file using msbuild or xbuild. | ||
| 120 | - """ | ||
| 124 | + """Builds the .pyd file using msbuild or xbuild""" | ||
| 121 | 125 | if ext.name != "clr": | |
| 122 | 126 | return build_ext.build_extension(self, ext) | |
| 123 | 127 | ||
@@ -129,8 +133,8 @@ def build_extension(self, ext): | |||
| 129 | 133 | if not os.path.exists(dest_dir): | |
| 130 | 134 | os.makedirs(dest_dir) | |
| 131 | 135 | ||
| 132 | - # Up to Python 3.2 sys.maxunicode is used to determine the size of Py_UNICODE | ||
| 133 | - # but from 3.3 onwards Py_UNICODE is a typedef of wchar_t. | ||
| 136 | + # Up to Python 3.2 sys.maxunicode is used to determine the size of | ||
| 137 | + # Py_UNICODE, but from 3.3 onwards Py_UNICODE is a typedef of wchar_t. | ||
| 134 | 138 | if sys.version_info[:2] <= (3, 2): | |
| 135 | 139 | unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4 | |
| 136 | 140 | else: | |
@@ -204,7 +208,8 @@ def _get_manifest(self, build_dir): | |||
| 204 | 208 | if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2, 5): | |
| 205 | 209 | mt = _find_msbuild_tool("mt.exe", use_windows_sdk=True) | |
| 206 | 210 | manifest = os.path.abspath(os.path.join(build_dir, "app.manifest")) | |
| 207 | - cmd = [mt, '-inputresource:"%s"' % sys.executable, '-out:"%s"' % manifest] | ||
| 211 | + cmd = [mt, '-inputresource:"%s"' % sys.executable, | ||
| 212 | + '-out:"%s"' % manifest] | ||
| 208 | 213 | self.announce("Extracting manifest from %s" % sys.executable) | |
| 209 | 214 | check_call(" ".join(cmd), shell=False) | |
| 210 | 215 | return manifest | |
@@ -282,8 +287,7 @@ def run(self): | |||
| 282 | 287 | ||
| 283 | 288 | def _check_output(*popenargs, **kwargs): | |
| 284 | 289 | """subprocess.check_output from python 2.7. | |
| 285 | - Added here to support building for earlier versions | ||
| 286 | - of Python. | ||
| 290 | + Added here to support building for earlier versions of Python. | ||
| 287 | 291 | """ | |
| 288 | 292 | process = Popen(stdout=PIPE, *popenargs, **kwargs) | |
| 289 | 293 | output, unused_err = process.communicate() | |
@@ -304,7 +308,7 @@ def _get_interop_filename(): | |||
| 304 | 308 | as most windows users won't have Clang installed, which is | |
| 305 | 309 | required to generate the file. | |
| 306 | 310 | """ | |
| 307 | - interop_file = "interop%d%s%s.cs" % (sys.version_info[0], sys.version_info[1], getattr(sys, "abiflags", "")) | ||
| 311 | + interop_file = "interop%d%d%s.cs" % (sys.version_info[0], sys.version_info[1], getattr(sys, "abiflags", "")) | ||
| 308 | 312 | return os.path.join("src", "runtime", interop_file) | |
| 309 | 313 | ||
| 310 | 314 | ||
@@ -336,18 +340,21 @@ def _get_interop_filename(): | |||
| 336 | 340 | name="pythonnet", | |
| 337 | 341 | version="2.2.0", | |
| 338 | 342 | description=".Net and Mono integration for Python", | |
| 339 | - url='http://pythonnet.github.io/', | ||
| 340 | - author="Python for .Net developers", | ||
| 343 | + url='https://pythonnet.github.io/', | ||
| 344 | + license='MIT', | ||
| 345 | + author="The Python for .Net developers", | ||
| 341 | 346 | classifiers=[ | |
| 347 | + 'Development Status :: 5 - Production/Stable', | ||
| 348 | + 'Intended Audience :: Developers', | ||
| 349 | + 'License :: OSI Approved :: MIT License', | ||
| 350 | + 'Programming Language :: C#', | ||
| 351 | + 'Programming Language :: Python :: 2', | ||
| 342 | 352 | 'Programming Language :: Python :: 2.7', | |
| 353 | + 'Programming Language :: Python :: 3', | ||
| 343 | 354 | 'Programming Language :: Python :: 3.3', | |
| 344 | 355 | 'Programming Language :: Python :: 3.4', | |
| 345 | 356 | 'Programming Language :: Python :: 3.5', | |
| 346 | 357 | 'Programming Language :: Python :: 3.6', | |
| 347 | - 'Programming Language :: C#', | ||
| 348 | - 'License :: OSI Approved :: MIT License', | ||
| 349 | - 'Development Status :: 5 - Production/Stable', | ||
| 350 | - 'Intended Audience :: Developers', | ||
| 351 | 358 | 'Operating System :: Microsoft :: Windows', | |
| 352 | 359 | 'Operating System :: POSIX :: Linux', | |
| 353 | 360 | 'Operating System :: MacOS :: MacOS X', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,6 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | """ | |
| 2 | 5 | TypeOffset is a C# class that mirrors the in-memory layout of heap | |
| 3 | 6 | allocated Python objects. | |
@@ -9,6 +12,9 @@ | |||
| 9 | 12 | - pycparser | |
| 10 | 13 | - clang | |
| 11 | 14 | """ | |
| 15 | + | ||
| 16 | + from __future__ import print_function | ||
| 17 | + | ||
| 12 | 18 | from distutils.sysconfig import get_config_var | |
| 13 | 19 | from subprocess import Popen, CalledProcessError, PIPE | |
| 14 | 20 | from pycparser import c_parser, c_ast | |
@@ -86,8 +92,8 @@ def visit_struct(self, struct): | |||
| 86 | 92 | self.__struct_members_stack.pop(0) | |
| 87 | 93 | self.__struct_stack.pop(0) | |
| 88 | 94 | elif self.__ptr_decl_depth: | |
| 89 | - # the struct is empty, but add it as a member to the current struct | ||
| 90 | - # as the current member maybe a pointer to it. | ||
| 95 | + # the struct is empty, but add it as a member to the current | ||
| 96 | + # struct as the current member maybe a pointer to it. | ||
| 91 | 97 | self.__add_struct_member(struct.name) | |
| 92 | 98 | ||
| 93 | 99 | def visit_decl(self, decl): | |
@@ -109,7 +115,8 @@ def __add_struct_member(self, type_name): | |||
| 109 | 115 | # add member to current struct | |
| 110 | 116 | current_struct = self.__struct_stack[0] | |
| 111 | 117 | member_name = self.__struct_members_stack[0] | |
| 112 | - struct_members = self.__struct_members.setdefault(self.__get_struct_name(current_struct), []) | ||
| 118 | + struct_members = self.__struct_members.setdefault( | ||
| 119 | + self.__get_struct_name(current_struct), []) | ||
| 113 | 120 | ||
| 114 | 121 | # get the node associated with this type | |
| 115 | 122 | node = None | |
@@ -118,7 +125,8 @@ def __add_struct_member(self, type_name): | |||
| 118 | 125 | elif type_name in self.__structs: | |
| 119 | 126 | node = self.__structs[type_name] | |
| 120 | 127 | ||
| 121 | - # If it's a struct (and not a pointer to a struct) expand it into the current struct definition | ||
| 128 | + # If it's a struct (and not a pointer to a struct) expand | ||
| 129 | + # it into the current struct definition | ||
| 122 | 130 | if not self.__ptr_decl_depth and isinstance(node, c_ast.Struct): | |
| 123 | 131 | for decl in node.decls or []: | |
| 124 | 132 | self.__struct_members_stack.insert(0, decl.name) | |
@@ -141,8 +149,7 @@ def __get_struct_name(self, node): | |||
| 141 | 149 | ||
| 142 | 150 | def check_output(*popenargs, **kwargs): | |
| 143 | 151 | """subprocess.check_output from python 2.7. | |
| 144 | - Added here to support building for earlier versions | ||
| 145 | - of Python. | ||
| 152 | + Added here to support building for earlier versions of Python. | ||
| 146 | 153 | """ | |
| 147 | 154 | process = Popen(stdout=PIPE, *popenargs, **kwargs) | |
| 148 | 155 | output, unused_err = process.communicate() | |
@@ -161,7 +168,8 @@ def preprocess_python_headers(): | |||
| 161 | 168 | """Return Python.h pre-processed, ready for parsing. | |
| 162 | 169 | Requires clang. | |
| 163 | 170 | """ | |
| 164 | - fake_libc_include = os.path.join(os.path.dirname(__file__), "fake_libc_include") | ||
| 171 | + fake_libc_include = os.path.join(os.path.dirname(__file__), | ||
| 172 | + "fake_libc_include") | ||
| 165 | 173 | include_dirs = [fake_libc_include] | |
| 166 | 174 | ||
| 167 | 175 | include_py = get_config_var("INCLUDEPY") | |
@@ -198,7 +206,7 @@ def gen_interop_code(members): | |||
| 198 | 206 | """Generate the TypeOffset C# class""" | |
| 199 | 207 | ||
| 200 | 208 | defines = [ | |
| 201 | - "PYTHON%d%s" % (sys.version_info[:2]) | ||
| 209 | + "PYTHON%d%d" % (sys.version_info[:2]) | ||
| 202 | 210 | ] | |
| 203 | 211 | ||
| 204 | 212 | if hasattr(sys, "abiflags"): | |
@@ -278,7 +286,7 @@ def main(): | |||
| 278 | 286 | interop_cs = gen_interop_code(members) | |
| 279 | 287 | ||
| 280 | 288 | if len(sys.argv) > 1: | |
| 281 | - with open(sys.argv[1], "wt") as fh: | ||
| 289 | + with open(sys.argv[1], "w") as fh: | ||
| 282 | 290 | fh.write(interop_cs) | |
| 283 | 291 | else: | |
| 284 | 292 | print(interop_cs) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments