コード例 #1
0
ファイル: nt.cs プロジェクト: jcteague/ironruby
            public stat_result(CodeContext/*!*/ context, ISequence statResult, [DefaultParameterValue(null)]PythonDictionary dict) {
                // dict is allowed by CPython's stat_result, but doesn't seem to do anything, so we ignore it here.

                if (statResult.__len__() < 10) {
                    throw PythonOps.TypeError("stat_result() takes an at least 10-sequence ({0}-sequence given)", statResult.__len__());
                }

                _mode = statResult[0];
                _ino = statResult[1];
                _dev = statResult[2];
                _nlink = statResult[3];
                _uid = statResult[4];
                _gid = statResult[5];
                _size = statResult[6];
                _atime = statResult[7];
                _mtime = statResult[8];
                _ctime = statResult[9];

                object dictTime;
                if (statResult.__len__() >= 11) {
                    _st_atime = TryShrinkToInt(statResult[10]);
                } else if (TryGetDictValue(dict, "st_atime", out dictTime)) {
                    _st_atime = dictTime;
                } else {
                    _st_atime = TryShrinkToInt(_atime);
                }

                if (statResult.__len__() >= 12) {
                    _st_mtime = TryShrinkToInt(statResult[11]);
                } else if (TryGetDictValue(dict, "st_mtime", out dictTime)) {
                    _st_mtime = dictTime;
                } else { 
                    _st_mtime = TryShrinkToInt(_mtime);
                }

                if (statResult.__len__() >= 13) {
                    _st_ctime = TryShrinkToInt(statResult[12]);
                } else if (TryGetDictValue(dict, "st_ctime", out dictTime)) {
                    _st_ctime = dictTime;
                } else { 
                    _st_ctime = TryShrinkToInt(_ctime);
                }
            }
コード例 #2
0
ファイル: Slice.cs プロジェクト: jcteague/ironruby
        private static void SequenceSliceAssign(SliceAssign assign, int start, int n, int step, ISequence lst) {
            if (lst.__len__() < n) throw PythonOps.ValueError("too few items in the enumerator. need {0}", n);
            else if (lst.__len__() != n) throw PythonOps.ValueError("too many items in the enumerator need {0}", n);

            for (int i = 0, index = start; i < n; i++, index += step) {
                assign(index, lst[i]);
            }

        }