• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Runtime.PythonContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IronPython.Runtime.PythonContext的典型用法代码示例。如果您正苦于以下问题:C# PythonContext类的具体用法?C# PythonContext怎么用?C# PythonContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PythonContext类属于IronPython.Runtime命名空间,在下文中一共展示了PythonContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: _FileIO

            public _FileIO(CodeContext/*!*/ context, int fd, [DefaultParameterValue("r")]string mode, [DefaultParameterValue(true)]bool closefd) {
                if (fd < 0) {
                    throw PythonOps.ValueError("fd must be >= 0");
                }

                PythonContext pc = PythonContext.GetContext(context);
                _FileIO file = (_FileIO)pc.FileManager.GetObjectFromId(pc, fd);
                Console.WriteLine(file);

                _context = pc;
                switch (mode) {
                    case "r": _mode = "rb"; break;
                    case "w": _mode = "wb"; break;
                    case "a": _mode = "w"; break;
                    case "r+":
                    case "+r": _mode = "rb+"; break;
                    case "w+":
                    case "+w": _mode = "rb+"; break;
                    case "a+":
                    case "+a": _mode = "r+"; break;
                    default:
                        BadMode(mode);
                        break;
                }
                _readStream = file._readStream;
                _writeStream = file._writeStream;
                _closefd = closefd;
            }
开发者ID:andreakn,项目名称:ironruby,代码行数:28,代码来源:_fileio.cs


示例2: CodeContext

        public CodeContext(Scope scope, PythonContext languageContext, CodeContext parent) {
            Assert.NotNull(languageContext);

            _languageContext = languageContext;
            _scope = scope;
            _parent = parent;
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:7,代码来源:CodeContext.cs


示例3: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {            
            var socket = context.GetBuiltinModule("socket");
            var socketError = PythonSocket.GetSocketError(context, socket.__dict__);
            
            context.EnsureModuleException("SSLError", socketError, dict, "SSLError", "ssl");

        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:7,代码来源:_ssl.cs


示例4: PerformModuleReload

        public static void PerformModuleReload(PythonContext context, PythonDictionary dict) {
            if (!context.HasModuleState(_zip_directory_cache_key))
                context.SetModuleState(_zip_directory_cache_key, new PythonDictionary());

            dict["_zip_directory_cache"] = context.GetModuleState(_zip_directory_cache_key);
            InitModuleExceptions(context, dict);
        }
开发者ID:Gerhman,项目名称:IronLanguages,代码行数:7,代码来源:zipimport.cs


示例5: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, IDictionary/*!*/ dict) {
     if (ucd_5_2_0 == null) {
         // This is a lie. The version of Unicode depends on the .NET version as well as the OS. The
         // version of the database stored internally is 5.2, so just say that.
         Interlocked.CompareExchange(ref ucd_5_2_0, new UCD("5.2.0"), null);
     }
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:7,代码来源:unicodedata.cs


示例6: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, IAttributesCollection dict) {
     Scope scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalScope.Dict, "itertools", false, -1) as Scope;
     if (scope != null) {
         dict[SymbolTable.StringToId("map")] = scope.LookupName(context, SymbolTable.StringToId("imap"));
         dict[SymbolTable.StringToId("filter")] = scope.LookupName(context, SymbolTable.StringToId("ifilter"));
         dict[SymbolTable.StringToId("zip")] = scope.LookupName(context, SymbolTable.StringToId("izip"));
     }
 }
开发者ID:xerxesb,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs


示例7: FormatString

        /// <summary>
        /// Runs the formatting operation on the given format and keyword arguments
        /// </summary>
        public static string/*!*/ FormatString(PythonContext/*!*/ context, string/*!*/ format, PythonTuple/*!*/ args, IAttributesCollection/*!*/ kwArgs) {
            ContractUtils.RequiresNotNull(context, "context");
            ContractUtils.RequiresNotNull(format, "format");
            ContractUtils.RequiresNotNull(args, "args");
            ContractUtils.RequiresNotNull(kwArgs, "kwArgs");

            return Formatter.FormatString(context, format, args, kwArgs);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:11,代码来源:NewStringFormatter.cs


示例8: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, IAttributesCollection dict) {
     PythonModule scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalDict, "itertools", false, -1) as PythonModule;
     if (scope != null) {
         dict[SymbolTable.StringToId("map")] = scope.__dict__["imap"];
         dict[SymbolTable.StringToId("filter")] = scope.__dict__["ifilter"];
         dict[SymbolTable.StringToId("zip")] = scope.__dict__["izip"];
     }
 }
开发者ID:techarch,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs


示例9: MakeSignalState

 private static PythonSignalState MakeSignalState(PythonContext context) {
     if (Environment.OSVersion.Platform == PlatformID.Unix
         || Environment.OSVersion.Platform == PlatformID.MacOSX) {
         return MakePosixSignalState(context);
     } else {
         return MakeNtSignalState(context);
     }
 }
开发者ID:TerabyteX,项目名称:ironpython3,代码行数:8,代码来源:signal.cs


示例10: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, PythonDictionary dict) {
     PythonModule scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalDict, "itertools", false, -1) as PythonModule;
     if (scope != null) {
         dict["map"] = scope.__dict__["imap"];
         dict["filter"] = scope.__dict__["ifilter"];
         dict["zip"] = scope.__dict__["izip"];
     }
 }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs


示例11: ModuleContext

        /// <summary>
        /// Creates a new ModuleContext for the specified module.
        /// </summary>
        public ModuleContext(PythonModule/*!*/ module, PythonContext/*!*/ creatingContext) {
            ContractUtils.RequiresNotNull(module, "module");
            ContractUtils.RequiresNotNull(creatingContext, "creatingContext");

            _globals = module.__dict__;
            _pyContext = creatingContext;
            _globalContext = new CodeContext(_globals, this);
            _module = module;
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:12,代码来源:ModuleContext.cs


示例12: StaticGlobalAllocator

        public StaticGlobalAllocator(PythonContext/*!*/ context, string name) {
            _typeGen = Snippets.Shared.DefineType(name, typeof(object), false, false);

            _codeContextField = _typeGen.AddStaticField(typeof(CodeContext), "__global_context");
            _codeContext = CreateFieldBuilderExpression(_codeContextField);

            _scope = new Scope(new PythonDictionary(new GlobalDictionaryStorage(_globalVals)));
            _context = new CodeContext(_scope, context);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:9,代码来源:StaticGlobalAllocator.cs


示例13: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
     context.EnsureModuleException("PickleError", dict, "PickleError", "cPickle");
     context.EnsureModuleException("PicklingError", dict, "PicklingError", "cPickle");
     context.EnsureModuleException("UnpicklingError", dict, "UnpicklingError", "cPickle");
     context.EnsureModuleException("UnpickleableError", dict, "UnpickleableError", "cPickle");
     context.EnsureModuleException("BadPickleGet", dict, "BadPickleGet", "cPickle");
     dict[Symbols.Builtins] = context.BuiltinModuleInstance;
     dict[SymbolTable.StringToId("compatible_formats")] = PythonOps.MakeList("1.0", "1.1", "1.2", "1.3", "2.0");
 }
开发者ID:techarch,项目名称:ironruby,代码行数:9,代码来源:cPickle.cs


示例14: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {
     context.EnsureModuleException("PickleError", dict, "PickleError", "cPickle");
     context.EnsureModuleException("PicklingError", dict, "PicklingError", "cPickle");
     context.EnsureModuleException("UnpicklingError", dict, "UnpicklingError", "cPickle");
     context.EnsureModuleException("UnpickleableError", dict, "UnpickleableError", "cPickle");
     context.EnsureModuleException("BadPickleGet", dict, "BadPickleGet", "cPickle");
     dict["__builtins__"] = context.BuiltinModuleInstance;
     dict["compatible_formats"] = PythonOps.MakeList("1.0", "1.1", "1.2", "1.3", "2.0");
 }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:9,代码来源:cPickle.cs


示例15: InitModuleExceptions

 private static void InitModuleExceptions(PythonContext context,
     PythonDictionary dict)
 {
     ZipImportError = context.EnsureModuleException(
         "zipimport.ZipImportError",
         PythonExceptions.ImportError,
         typeof(PythonExceptions.BaseException),
         dict, "ZipImportError", "zipimport",
         msg => new ImportException(msg));
 }
开发者ID:TerabyteX,项目名称:main,代码行数:10,代码来源:zipimport.cs


示例16: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
     dict.Add(SymbolTable.StringToId(_keyDefaultAction), "default");
     dict.Add(SymbolTable.StringToId(_keyOnceRegistry), new PythonDictionary());
     dict.Add(SymbolTable.StringToId(_keyFilters), new List() {
         // Default filters
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.PendingDeprecationWarning, null, 0),
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.ImportWarning, null, 0),
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.BytesWarning, null, 0)
     });
     context.SetModuleState(_keyFields, dict);
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:11,代码来源:_warnings.cs


示例17: FunctionCode

        /// <summary>
        /// Constructor used to create a FunctionCode for code that's been serialized to disk.  
        /// 
        /// Code constructed this way cannot be interpreted or debugged using sys.settrace/sys.setprofile.
        /// 
        /// Function codes created this way do support recursion enforcement and are therefore registered in the global function code registry.
        /// </summary>
        internal FunctionCode(PythonContext context, Delegate code, Compiler.Ast.ScopeStatement scope, string documentation, int localCount) {
            _normalDelegate = code;
            _lambda = scope;
            _argCount = CalculateArgumentCount();

            // need to take this lock to ensure sys.settrace/sys.setprofile is not actively changing
            lock (_CodeCreateAndUpdateDelegateLock) {
                Target = AddRecursionCheck(context, code);
            }

            RegisterFunctionCode(context);
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:19,代码来源:FunctionCode.cs


示例18: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {
            if (!context.HasModuleState(_defaultTimeoutKey)) {
                context.SetModuleState(_defaultTimeoutKey, null);
            }

            context.SetModuleState(_defaultBufsizeKey, DefaultBufferSize);

            PythonType socketErr = GetSocketError(context, dict);
            context.EnsureModuleException("socketherror", socketErr, dict, "herror", "socket");
            context.EnsureModuleException("socketgaierror", socketErr, dict, "gaierror", "socket");
            context.EnsureModuleException("sockettimeout", socketErr, dict, "timeout", "socket");
        }
开发者ID:TerabyteX,项目名称:main,代码行数:12,代码来源:socket.cs


示例19: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
            if (!context.HasModuleState(_defaultTimeoutKey)) {
                context.SetModuleState(_defaultTimeoutKey, null);
            }

            context.SetModuleState(_defaultBufsizeKey, DefaultBufferSize);

            context.EnsureModuleException("sslerror", dict, "sslerror", "socket");
            PythonType socketErr = context.EnsureModuleException("socketerror", PythonExceptions.IOError, dict, "error", "socket");
            context.EnsureModuleException("socketherror", socketErr, dict, "herror", "socket");
            context.EnsureModuleException("socketgaierror", socketErr, dict, "gaierror", "socket");
            context.EnsureModuleException("sockettimeout", socketErr, dict, "timeout", "socket");
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:13,代码来源:socket.cs


示例20: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {
     context.GetOrCreateModuleState(_keyFields, () => {
         dict.Add(_keyDefaultAction, "default");
         dict.Add(_keyOnceRegistry, new PythonDictionary());
         dict.Add(_keyFilters, new List() {
             // Default filters
             PythonTuple.MakeTuple("ignore", null, PythonExceptions.PendingDeprecationWarning, null, 0),
             PythonTuple.MakeTuple("ignore", null, PythonExceptions.ImportWarning, null, 0),
             PythonTuple.MakeTuple("ignore", null, PythonExceptions.BytesWarning, null, 0)
         });
         return dict;
     });
 }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:13,代码来源:_warnings.cs



注:本文中的IronPython.Runtime.PythonContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.PythonModule类代码示例发布时间:2022-05-26
下一篇:
C# Runtime.List类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap