Convert a Python type into CLIPS.
776086
def clips_value(self, dvalue):
        """"""
        try:
            return VALUES[type(dvalue)](self._env, dvalue)
        except KeyError:
            if isinstance(dvalue, (list, tuple)):
                return self.list_to_multifield(dvalue)
            if isinstance(dvalue, (clips.facts.Fact)):
                return dvalue._fact
            if isinstance(dvalue, (clips.classes.Instance)):
                return dvalue._ist

        return ffi.NULL
341864
def to_python(self) -> typing.List:
        
        self.clean()
        result = []
        for obj in self.media:
            if isinstance(obj, base.TelegramObject):
                obj = obj.to_python()
            result.append(obj)
        return result
797296
def _cast_output_to_type(value, typ):
    ''''''
    if typ == 'b':
        return bool(value)
    if typ == 'i':
        return int(value)
    return value
619748
def create(cls, type):
        
        if type == 0: return TagEnd()
        elif type == 1: return TagShowFrame()
        elif type == 2: return TagDefineShape()
        elif type == 4: return TagPlaceObject()
        elif type == 5: return TagRemoveObject()
        elif type == 6: return TagDefineBits()
        elif type == 7: return TagDefineButton()
        elif type == 8: return TagJPEGTables()
        elif type == 9: return TagSetBackgroundColor()
        elif type == 10: return TagDefineFont()
        elif type == 11: return TagDefineText()
        elif type == 12: return TagDoAction()
        elif type == 13: return TagDefineFontInfo()
        elif type == 14: return TagDefineSound()
        elif type == 15: return TagStartSound()
        elif type == 17: return TagDefineButtonSound()
        elif type == 18: return TagSoundStreamHead()
        elif type == 19: return TagSoundStreamBlock()
        elif type == 20: return TagDefineBitsLossless()
        elif type == 21: return TagDefineBitsJPEG2()
        elif type == 22: return TagDefineShape2()
        elif type == 24: return TagProtect()
        elif type == 26: return TagPlaceObject2()
        elif type == 28: return TagRemoveObject2()
        elif type == 32: return TagDefineShape3()
        elif type == 33: return TagDefineText2()
        elif type == 34: return TagDefineButton2()
        elif type == 35: return TagDefineBitsJPEG3()
        elif type == 36: return TagDefineBitsLossless2()
        elif type == 37: return TagDefineEditText()
        elif type == 39: return TagDefineSprite()
        elif type == 41: return TagProductInfo()
        elif type == 43: return TagFrameLabel()
        elif type == 45: return TagSoundStreamHead2()
        elif type == 46: return TagDefineMorphShape()
        elif type == 48: return TagDefineFont2()
        elif type == 56: return TagExportAssets()
        elif type == 58: return TagEnableDebugger()
        elif type == 59: return TagDoInitAction()
        elif type == 60: return TagDefineVideoStream()
        elif type == 61: return TagVideoFrame()
        elif type == 63: return TagDebugID()
        elif type == 64: return TagEnableDebugger2()
        elif type == 65: return TagScriptLimits()
        elif type == 69: return TagFileAttributes()
        elif type == 70: return TagPlaceObject3()
        elif type == 73: return TagDefineFontAlignZones()
        elif type == 74: return TagCSMTextSettings()
        elif type == 75: return TagDefineFont3()
        elif type == 76: return TagSymbolClass()
        elif type == 77: return TagMetadata()
        elif type == 78: return TagDefineScalingGrid()
        elif type == 82: return TagDoABC()
        elif type == 83: return TagDefineShape4()
        elif type == 84: return TagDefineMorphShape2()
        elif type == 86: return TagDefineSceneAndFrameLabelData()
        elif type == 87: return TagDefineBinaryData()
        elif type == 88: return TagDefineFontName()
        elif type == 89: return TagStartSound2()
        else: return None
572986
def pycode(argcount,
           kwonlyargcount,
           nlocals,
           stacksize,
           flags,
           codestring,
           constants,
           names,
           varnames,
           filename,
           name,
           firstlineno,
           lnotab,
           freevars=(),
           cellvars=()):
    
    return CodeType(
        argcount,
        kwonlyargcount,
        nlocals,
        stacksize,
        flags,
        codestring,
        constants,
        names,
        varnames,
        filename,
        name,
        firstlineno,
        lnotab,
        freevars,
        cellvars,
    )
185329
def clip( range = 0 .. 0xFF )
      if range.exclude_end?
        raise "Clipping does not support ranges with end value " +
              "excluded (such as #{range})"
      end
      collect { |x| x.major( range.begin ).minor range.end }
    end
490062
function(clipData) {
    var newClipData = {}, formatMap = {};
    if (!(typeof clipData === "object" && clipData)) {
      return;
    }
    for (var dataFormat in clipData) {
      if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
        switch (dataFormat.toLowerCase()) {
         case "text/plain":
         case "text":
         case "air:text":
         case "flash:text":
          newClipData.text = clipData[dataFormat];
          formatMap.text = dataFormat;
          break;

         case "text/html":
         case "html":
         case "air:html":
         case "flash:html":
          newClipData.html = clipData[dataFormat];
          formatMap.html = dataFormat;
          break;

         case "application/rtf":
         case "text/rtf":
         case "rtf":
         case "richtext":
         case "air:rtf":
         case "flash:rtf":
          newClipData.rtf = clipData[dataFormat];
          formatMap.rtf = dataFormat;
          break;

         default:
          break;
        }
      }
    }
    return {
      data: newClipData,
      formatMap: formatMap
    };
  }
850347
def get_clipboard_text_and_convert(paste_list=False):
    """
    txt = GetClipboardText()
    if txt:
        if paste_list and u"\t" in txt:
            array, flag = make_list_of_list(txt)
            if flag:
                txt = repr(array)
            else:
                txt = u"array(%s)"%repr(array)
            txt = u"".join([c for c in txt if c not in u" \t\r\n"])
    return txt
1356063
def clip(self, X):
        
        X = np.asarray(X)
        if self.min_value is not None:
            X[X < self.min_value] = self.min_value
        if self.max_value is not None:
            X[X > self.max_value] = self.max_value
        return X
904932
def pytype_to_ctype(t):
    
    if isinstance(t, List):
        return 'pythonic::types::list<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Set):
        return 'pythonic::types::set<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Dict):
        tkey, tvalue = t.__args__
        return 'pythonic::types::dict<{0},{1}>'.format(pytype_to_ctype(tkey),
                                                       pytype_to_ctype(tvalue))
    elif isinstance(t, Tuple):
        return 'decltype(pythonic::types::make_tuple({0}))'.format(
            ", ".join('std::declval<{}>()'.format(pytype_to_ctype(p))
                      for p in t.__args__)
        )
    elif isinstance(t, NDArray):
        dtype = pytype_to_ctype(t.__args__[0])
        ndim = len(t.__args__) - 1
        shapes = ','.join(('long'
                           if s.stop == -1 or s.stop is None
                           else 'std::integral_constant<long, {}>'.format(
                               s.stop)
                           ) for s in t.__args__[1:])
        pshape = 'pythonic::types::pshape<{0}>'.format(shapes)
        arr = 'pythonic::types::ndarray<{0},{1}>'.format(
                    dtype, pshape)
        if t.__args__[1].start == -1:
            return 'pythonic::types::numpy_texpr<{0}>'.format(arr)
        elif any(s.step is not None and s.step < 0 for s in t.__args__[1:]):
            slices = ", ".join(['pythonic::types::normalized_slice'] * ndim)
            return 'pythonic::types::numpy_gexpr<{0},{1}>'.format(arr, slices)
        else:
            return arr
    elif isinstance(t, Pointer):
        return 'pythonic::types::pointer<{0}>'.format(
            pytype_to_ctype(t.__args__[0])
        )
    elif isinstance(t, Fun):
        return 'pythonic::types::cfun<{0}({1})>'.format(
            pytype_to_ctype(t.__args__[-1]),
            ", ".join(pytype_to_ctype(arg) for arg in t.__args__[:-1]),
        )
    elif t in PYTYPE_TO_CTYPE_TABLE:
        return PYTYPE_TO_CTYPE_TABLE[t]
    else:
        raise NotImplementedError("{0}:{1}".format(type(t), t))
1186939
def _wrap_type_instantiation(self, type_cls):
        """"""
        def wrapper(*args, **kwargs):
            # use args for struct arguments??
            return type_cls(stream=self._null_stream)
        return wrapper
415834
def _to_pywintypes(row):
    """"""
    def _pywintype(x):
        if isinstance(x, dt.date):
            return dt.datetime(x.year, x.month, x.day, tzinfo=dt.timezone.utc)

        elif isinstance(x, (dt.datetime, pa.Timestamp)):
            if x.tzinfo is None:
                return x.replace(tzinfo=dt.timezone.utc)

        elif isinstance(x, str):
            if re.match("^\d{4}-\d{2}-\d{2}$", x):
                return "'" + x
            return x

        elif isinstance(x, np.integer):
            return int(x)

        elif isinstance(x, np.floating):
            return float(x)

        elif x is not None and not isinstance(x, (str, int, float, bool)):
            return str(x)

        return x

    return [_pywintype(x) for x in row]
1052236
def python_value(self, dtype, dvalue):
        """"""
        try:
            return CONVERTERS[dtype](dvalue)
        except KeyError:
            if dtype == clips.common.CLIPSType.MULTIFIELD:
                return self.multifield_to_list()
            if dtype == clips.common.CLIPSType.FACT_ADDRESS:
                return clips.facts.new_fact(self._env, lib.to_pointer(dvalue))
            if dtype == clips.common.CLIPSType.INSTANCE_ADDRESS:
                return clips.classes.Instance(self._env, lib.to_pointer(dvalue))

        return None
25425
def _dtype_array(self):
        """"""
        attrtype = []
        attrdiff = []

        for key in self._headers:
            if self.attr[key][0] == 'continuous':
                attrtype.append(1)
            else:
                attrtype.append(0)
            attrdiff.append(self.attr[key][3])

        attrtype = np.array(attrtype)
        cidx = np.where(attrtype == 1)[0]
        didx = np.where(attrtype == 0)[0]

        attrdiff = np.array(attrdiff)

        return attrdiff, cidx, didx
731919
def paste(**kwargs):
    """"""

    clip.OpenClipboard() 
    d = clip.GetClipboardData(win32con.CF_UNICODETEXT)
    clip.CloseClipboard() 
    return d
104320
def clip(self, min=None, max=None):
        
        return self._constructor(
            self.values.clip(min=min, max=max)).__finalize__(self)
996813
def videogrep(inputfile, outputfile, search, searchtype, maxclips=0, padding=0, test=False, randomize=False, sync=0, use_transcript=False, use_vtt=False, export_clips=False):
    

    padding = padding / 1000.0
    sync = sync / 1000.0
    composition = []
    foundSearchTerm = False

    if use_transcript:
        composition = compose_from_transcript(inputfile, search, searchtype)
    elif use_vtt:
        vtts = get_vtt_files(inputfile)
        composition = compose_from_vtt(vtts, search, searchtype)
    else:
        srts = get_subtitle_files(inputfile)
        composition = compose_from_srts(srts, search, searchtype)


    # If the search term was not found in any subtitle file...
    if len(composition) == 0:
        print("[!] Search term '" + search + "'" + " was not found in any file.")
        exit(1)

    else:
        print("[+] Search term '" + search + "'" + " was found in " + str(len(composition)) + " places.")

        # apply padding and sync
        for c in composition:
            c['start'] = c['start'] + sync - padding
            c['end'] = c['end'] + sync + padding

        if maxclips > 0:
            composition = composition[:maxclips]

        if randomize is True:
            random.shuffle(composition)

        if test is True:
            demo_supercut(composition, padding)
        else:
            if os.path.splitext(outputfile)[1].lower() == '.edl':
                make_edl(composition, outputfile)
            elif export_clips:
                split_clips(composition, outputfile)
            else:
                if len(composition) > BATCH_SIZE:
                    print("[+} Starting batch job.")
                    create_supercut_in_batches(composition, outputfile, padding)
                else:
                    create_supercut(composition, outputfile, padding)