Useful functions
481928
function getCharacteristicFormatsKey(format) {
  // coerce 'int32' to 'int'
  if (format == 'int32') format = 'int';

  // look up the key in our known-formats dict
  for (var key in Characteristic.Formats)
    if (Characteristic.Formats[key] == format)
      return key;

  throw new Error("Unknown characteristic format '" + format + "'");
}
1151366
def create_function_f_c(self):
        """"""
        return ca.Function(
            'f_c',
            [self.t, self.x, self.y, self.m, self.p, self.ng, self.nu],
            [self.f_c],
            ['t', 'x', 'y', 'm', 'p', 'ng', 'nu'], ['c'], self.func_opt)
775005
function(func, context, argCount) {
                if (context === void 0) return func;
                switch (argCount == null ? 3 : argCount) {
                  case 1: return function(value) {
                    return func.call(context, value);
                  };
                  case 2: return function(value, other) {
                    return func.call(context, value, other);
                  };
                  case 3: return function(value, index, collection) {
                    return func.call(context, value, index, collection);
                  };
                  case 4: return function(accumulator, value, index, collection) {
                    return func.call(context, accumulator, value, index, collection);
                  };
                }
                return function() {
                  return func.apply(context, arguments);
                };
              }
89053
def functions(self):
        
        if self._functions is None:
            self._functions = FunctionList(self._version, service_sid=self._solution['sid'], )
        return self._functions
1261298
def _at_dump_functions(self, calculator, rule, scope, block):
        
        sys.stderr.write("%s\n" % repr(rule.namespace._functions))
820327
def ui_func(cls, id_, name, function_type, avail_fn=always):
    """"""
    return cls(id_, name, 0, 0, function_type, FUNCTION_TYPES[function_type],
               avail_fn)
1003472
def functions(self):
        
        names = []

        for i, k in enumerate(self.obj):
            if _(self.obj[k]).isCallable():
                names.append(k)

        return self._wrap(sorted(names))
176719
def _do_functions(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name):
        
        if name:
            funct, params, _ = name.partition('(')
            funct = funct.strip()
            params = split_params(depar(params + _))
            defaults = {}
            new_params = []
            for param in params:
                param, _, default = param.partition(':')
                param = param.strip()
                default = default.strip()
                if param:
                    new_params.append(param)
                    if default:
                        default = self.apply_vars(
                            default, rule[CONTEXT], None, rule)
                        defaults[param] = default
            context = rule[CONTEXT].copy()
            for p in new_params:
                context.pop(p, None)
            mixin = [list(new_params), defaults, self.
                     apply_vars(c_codestr, context, None, rule)]
            if code == '@function':
                def _call(mixin):
                    def __call(R, *args, **kwargs):
                        m_params = mixin[0]
                        m_vars = rule[CONTEXT].copy()
                        m_vars.update(mixin[1])
                        m_codestr = mixin[2]
                        for i, a in enumerate(args):
                            m_vars[m_params[i]] = a
                        m_vars.update(kwargs)
                        _options = rule[OPTIONS].copy()
                        _rule = spawn_rule(R, codestr=m_codestr, context=m_vars, options=_options, deps=set(), properties=[], final=False, lineno=c_lineno)
                        self.manage_children(_rule, p_selectors, p_parents,
                                             p_children, (scope or '') + '', R[MEDIA])
                        ret = _rule[OPTIONS].pop('@return', '')
                        return ret
                    return __call
                _mixin = _call(mixin)
                _mixin.mixin = mixin
                mixin = _mixin
            # Insert as many @mixin options as the default parameters:
            while len(new_params):
                rule[OPTIONS]['%s %s:%d' % (code, funct,
                                            len(new_params))] = mixin
                param = new_params.pop()
                if param not in defaults:
                    break
            if not new_params:
                rule[OPTIONS][code + ' ' + funct + ':0'] = mixin
269776
def _construct_functions(self, coefs, **kwargs):
        """"""
        return [self.basis_functions.functions_factory(coef, **kwargs) for coef in coefs]
993937
def function(self, rule, args, **kwargs):
        
        fname = rule.function
        try:
            return self.functions[fname](args)
        except KeyError:
            raise FilteringRuleException("Invalid function name '{}'".format(fname))
205303
function (fn) {
        return function () {
            var tokens = arguments;
            var i;

            for (i = 0; i < tokens.length; i += 1) {
                fn.call(this, tokens[i]);
            }
        };
    }
687069
def free_functions(
            self,
            name=None,
            function=None,
            return_type=None,
            arg_types=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        

        return (
            self._find_multiple(
                scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[namespace_t.free_function],
                return_type=return_type,
                arg_types=arg_types,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
1341084
def select_functions(expr):
    
    body = Group(expr)
    return Group(
        function("timestamp", body, caseless=True)
        | function("ts", body, caseless=True)
        | function("utctimestamp", body, caseless=True)
        | function("utcts", body, caseless=True)
        | function("now", caseless=True)
        | function("utcnow", caseless=True)
    ).setResultsName("function")
720152
function setFunction(descriptor,key,set,update)
        {
          var _descriptor = descriptor,
              _descVal = _descriptor.value,
              _key = key,
              _set = set,
              _update = update,
              _action;
          return function functionSet()
          {
            if(_set(this,_key,null,null,arguments,this._stopChange))
            {
              _action = _descVal.apply(this,arguments);
            }
            if(!this._stopChange)
            {
              _update(this,_key,null,null,arguments,_action);
            }
            this._stopChange = undefined;
            return _action;
          }
        }
751935
function helpPlugin() {
  return function(app) {

    // style to turn `[ ]` strings into
    // colored strings with backticks
    app.style('codify', function(msg) {
      var re = /\[([^\]]*\[?[^\]]*\]?[^[]*)\]/g;
      return msg.replace(re, function(str, code) {
        return this.red('`' + code + '`');
      }.bind(this));
    });

    // style and format a single help command
    app.style('helpCommand', function(command) {
      var msg = '';
      msg += this.bold(command.name.substr(0, 1).toUpperCase() +
                       command.name.substr(1) + ': ');
      msg += this.bold(command.description);
      return msg;
    });

    // style and format an array of help commands
    app.style('helpCommands', function(commands) {
      return commands
        .map(this.helpCommand)
        .join('\n\n');
    });

    // style and format a single example
    app.style('helpExample', function(example) {
      var msg = '';
      msg += ' ' + this.gray('# ' + example.description) + '\n';
      msg += ' ' + this.white('$ ' + example.command);
      return msg;
    });

    // style and format an array of examples
    app.style('helpExamples', function(examples) {
      return examples
        .map(this.helpExample)
        .join('\n\n');
    });

    // style and format a single option
    app.style('helpOption', function(option) {
      var msg = '';
      msg += ' ' + (option.flag ? this.bold(option.flag) : '  ');
      msg += ' ' + this.bold(option.name);
      msg += ' ' + this.bold(this.codify(option.description));
      return msg;
    });

    // style and format an array of options
    app.style('helpOptions', function(options) {
      return options
        .map(this.helpOption)
        .join('\n');
    });

    // style and formation a help text object using
    // other styles to break up responibilities
    app.emitter('help', function(help) {
      var msg = '\n';
      msg += this.bold('Usage: ') + this.cyan(help.usage) + '\n\n';
      msg += this.helpCommands(help.commands);

      if (help.examples && help.examples.length) {
        msg += this.bold('Examples:\n\n');
        msg += this.helpExamples(help.examples);
      }

      if (help.options && help.options.length) {
        msg += this.bold('Options:\n\n');
        msg += this.helpOptions(help.options);
      }
      return msg + '\n';
    });
  };
}
150996
function fun (graph, additionalFunctions) {
  // First of all, check if graph is valid.
  try {
    validate(graph, additionalFunctions)
  } catch (err) {
    throw err
  }

  var func = graph.func || {}
  var pipe = graph.pipe
  var task = graph.task

  var cachedLevelOf = {}
  var computeLevelOf = level.bind(null, pipe, cachedLevelOf)
  var funcs = builtinFunctions

  // Inject compile-time builtin tasks.

  funcs['dflow.fun'] = fun
  funcs['dflow.isDflowFun'] = isDflowFun
  funcs['dflow.validate'] = validate

  injectAccessors(funcs, graph)
  injectAdditionalFunctions(funcs, additionalFunctions)
  injectDotOperators(funcs, task)
  injectGlobals(funcs, task)
  injectReferences(funcs, task)
  injectStrings(funcs, task)
  injectNumbers(funcs, task)
  evalTasks(funcs, task)

  /**
   * Compiles a sub graph.
   */

  function compileSubgraph (key) {
    var subGraph = graph.func[key]

    var funcName = '/' + key

    funcs[funcName] = fun(subGraph, additionalFunctions)
  }

  /**
   * Sorts tasks by their level.
   */

  function byLevel (a, b) {
    if (no(cachedLevelOf[a])) cachedLevelOf[a] = computeLevelOf(a)

    if (no(cachedLevelOf[b])) cachedLevelOf[b] = computeLevelOf(b)

    return cachedLevelOf[a] - cachedLevelOf[b]
  }

  /**
   * Ignores comments.
   */

  function comments (key) {
    return !regexComment.test(task[key])
  }

  // Compile each subgraph.
  Object.keys(func)
    .forEach(compileSubgraph)

  /**
   * Throw if a task is not compiled.
   */

  function checkTaskIsCompiled (taskKey) {
    var taskName = task[taskKey]

    // Ignore tasks injected at run time.
    if (reservedKeys.indexOf(taskName) > -1) return

    var msg = 'Task not compiled: ' + taskName + ' [' + taskKey + ']'

    // Check subgraphs.
    if (regexSubgraph.test(taskName)) {
      var subgraphKey = taskName.substring(1)

      if (no(graph.func[subgraphKey])) {
        var subgraphNotFound = new Error(msg)
        subgraphNotFound.taskKey = taskKey
        subgraphNotFound.taskName = taskName
        throw subgraphNotFound
      } else return
    }

    // Skip dflow DSL.
    if (isDflowDSL(taskName)) return

    // Skip globals.
    if (walkGlobal(taskName)) return

    if (no(funcs[taskName])) {
      var subgraphNotCompiled = new Error(msg)
      subgraphNotCompiled.taskKey = taskKey
      subgraphNotCompiled.taskName = taskName
      throw subgraphNotCompiled
    }
  }

  // Check if there is some missing task.
  Object.keys(task)
    .filter(comments)
    .forEach(checkTaskIsCompiled)

  /**
   * Here we are, this is the ❤ of dflow.
   */

  function dflowFun () {
    var gotReturn = false
    var returnValue
    var outs = {}

    // Inject run-time builtin tasks.

    funcs['this'] = function () { return dflowFun }
    funcs['this.graph'] = function () { return graph }
    injectArguments(funcs, task, arguments)

    /**
     * Execute task.
     */

    function run (taskKey) {
      var args = inputArgs(outs, pipe, taskKey)
      var taskName = task[taskKey]
      var f = funcs[taskName]

      // Behave like a JavaScript function:
      // if found a return, skip all other tasks.

      if (gotReturn) return

      if ((taskName === 'return') && (!gotReturn)) {
        returnValue = args[0]
        gotReturn = true
        return
      }

      // If task is not defined at run time, throw an error.

      if (no(f)) {
        var taskNotFound = new Error('Task not found: ' + taskName + ' [' + taskKey + '] ')
        taskNotFound.taskKey = taskKey
        taskNotFound.taskName = taskName
      }

      // Try to execute task.

      try {
        outs[taskKey] = f.apply(null, args)
      } catch (err) {
        // Enrich error with useful dflow task info.
        err.taskName = taskName
        err.taskKey = taskKey

        throw err
      }
    }

    // Run every graph task, sorted by level.

    Object.keys(task)
      .filter(comments)
      .sort(byLevel)
      .forEach(run)

    return returnValue
  }

  // Remember function was created from a dflow graph.

  dflowFun.graph = graph

  return dflowFun
}
628897
def help_func():
    
    tprint("art")
    tprint("v" + VERSION)
    print(DESCRIPTION + "\n")
    print("Webpage : http://art.shaghighi.ir\n")
    print("Help : \n")
    print("     - list --> (list of arts)\n")
    print("     - fonts --> (list of fonts)\n")
    print("     - test --> (run tests)\n")
    print("     - text 'yourtext' 'font(optional)' --> (text art) Example : 'python -m art text exampletext block'\n")
    print("     - shape 'shapename' --> (shape art) Example : 'python -m art shape butterfly'\n")
    print("     - save 'yourtext' 'font(optional)'  -->  Example : 'python -m art save exampletext block'\n")
    print("     - all 'yourtext'  -->  Example : 'python -m art all exampletext'")