当前位置: 首页>>代码示例>>C#>>正文


C# PythonDictionary.Add方法代码示例

本文整理汇总了C#中PythonDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PythonDictionary.Add方法的具体用法?C# PythonDictionary.Add怎么用?C# PythonDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PythonDictionary的用法示例。


在下文中一共展示了PythonDictionary.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {
            List defaultFilters = new List();
            if (context.PythonOptions.WarnPython30) {
                defaultFilters.AddNoLock(PythonTuple.MakeTuple("ignore", null, PythonExceptions.DeprecationWarning, null, 0));
            }
            defaultFilters.AddNoLock(PythonTuple.MakeTuple("ignore", null, PythonExceptions.PendingDeprecationWarning, null, 0));
            defaultFilters.AddNoLock(PythonTuple.MakeTuple("ignore", null, PythonExceptions.ImportWarning, null, 0));
            defaultFilters.AddNoLock(PythonTuple.MakeTuple("ignore", null, PythonExceptions.BytesWarning, null, 0));

            context.GetOrCreateModuleState(_keyFields, () => {
                dict.Add(_keyDefaultAction, "default");
                dict.Add(_keyOnceRegistry, new PythonDictionary());
                dict.Add(_keyFilters, defaultFilters);
                return dict;
            });
        }
开发者ID:jschementi,项目名称:iron,代码行数:16,代码来源:_warnings.cs

示例3: ReadDirectory

            /// <summary>
            /// Given a path to a Zip archive, build a dict, mapping file names
            /// (local to the archive, using SEP as a separator) to toc entries.
            /// 
            /// A toc_entry is a tuple:
            /// (__file__,      # value to use for __file__, available for all files
            ///  compress,      # compression kind; 0 for uncompressed
            ///  data_size,     # size of compressed data on disk
            ///  file_size,     # size of decompressed data
            ///  file_offset,   # offset of file header from start of archive
            ///  time,          # mod time of file (in dos format)
            ///  date,          # mod data of file (in dos format)
            ///  crc,           # crc checksum of the data
            ///  )
            /// Directories can be recognized by the trailing SEP in the name,
            /// data_size and file_offset are 0.
            /// </summary>
            /// <param name="archive"></param>
            /// <returns></returns>
            private PythonDictionary ReadDirectory(string archive) {
                string path, name = string.Empty;
                BinaryReader fp = null;
                int header_position, header_size, header_offset, count, compress;
                int time, date, crc, data_size, name_size, file_size, file_offset;
                int arc_offset; // offset from beginning of file to start of zip-archive 
                PythonDictionary files = null;
                byte[] endof_central_dir = new byte[22];

                if (archive.Length > MAXPATHLEN) {
                    throw PythonOps.OverflowError("Zip path name is too long");
                }

                path = archive;
                try {
                    try {
                        fp = new BinaryReader(new FileStream(archive, FileMode.Open, FileAccess.Read));
                    } catch {
                        throw MakeError("can't open Zip file: '{0}'", archive);
                    }

                    if (fp.BaseStream.Length < 2) {
                        throw MakeError("can't read Zip file: '{0}'", archive);
                    }

                    fp.BaseStream.Seek(-22, SeekOrigin.End);
                    header_position = (int)fp.BaseStream.Position;
                    if (fp.Read(endof_central_dir, 0, 22) != 22) {
                        throw MakeError("can't read Zip file: '{0}'", archive);
                    }

                    if (BitConverter.ToUInt32(endof_central_dir, 0) != 0x06054B50) {
                        // Bad: End of Central Dir signature
                        fp.Close();
                        throw MakeError("not a Zip file: '{0}'", archive);
                    }

                    header_size = BitConverter.ToInt32(endof_central_dir, 12);
                    header_offset = BitConverter.ToInt32(endof_central_dir, 16);
                    arc_offset = header_position - header_offset - header_size;
                    header_offset += arc_offset;

                    files = new PythonDictionary();
                    path += Path.DirectorySeparatorChar;

                    // Start of Central Directory
                    count = 0;
                    while (true) {
                        name = string.Empty;
                        fp.BaseStream.Seek(header_offset, SeekOrigin.Begin); // Start of file header
                        int l = fp.ReadInt32();
                        if (l != 0x02014B50) {
                            break; // Bad: Central Dir File Header
                        }
                        fp.BaseStream.Seek(header_offset + 10, SeekOrigin.Begin);
                        compress = fp.ReadInt16();
                        time = fp.ReadInt16();
                        date = fp.ReadInt16();
                        crc = fp.ReadInt32();
                        data_size = fp.ReadInt32();
                        file_size = fp.ReadInt32();
                        name_size = fp.ReadInt16();
                        header_size = 46 + name_size +
                            fp.ReadInt16() +
                            fp.ReadInt16();

                        fp.BaseStream.Seek(header_offset + 42, SeekOrigin.Begin);
                        file_offset = fp.ReadInt32() + arc_offset;
                        if (name_size > MAXPATHLEN)
                            name_size = MAXPATHLEN;

                        for (int i = 0; i < name_size; i++) {
                            char c = fp.ReadChar();
                            if (c == '/')
                                c = Path.DirectorySeparatorChar;
                            name += c;
                        }
                        header_offset += header_size;

                        PythonTuple t = PythonOps.MakeTuple(path + name, compress, data_size, file_size, file_offset, time, date, crc);
                        files.Add(name, t);
//.........这里部分代码省略.........
开发者ID:Gerhman,项目名称:IronLanguages,代码行数:101,代码来源:zipimport.cs

示例4: eval

        private object eval(IFreeDocument doc)
        {
            var value = doc[Column];

            var dictionary = new PythonDictionary();
            foreach (var data1 in doc)
            {
                dictionary.Add(data1.Key, data1.Value);
            }
            scope.SetVariable("data", dictionary);
            scope.SetVariable("value", value);
            foreach (var data in doc)
            {
                scope.SetVariable(data.Key, data.Value);
            }
            dynamic d;
            try
            {
                d = compiledCode.Execute(scope);
            }
            catch (Exception ex)
            {
                d = ex.Message;
            }
            return d;
        }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:26,代码来源:PythonTF.cs


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