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

Python helpers.typecheck函数代码示例

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

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



在下文中一共展示了typecheck函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: enumerate_artifacts

 def enumerate_artifacts(self, artifact_enumerator):
   typecheck(artifact_enumerator, ArtifactEnumerator)
   value = artifact_enumerator.read(self.__condition_artifact)
   if value == "true":
     self.__true_command.enumerate_artifacts(artifact_enumerator)
   elif value == "false" and self.__false_command is not None:
     self.__false_command.enumerate_artifacts(artifact_enumerator)
开发者ID:sholiday,项目名称:cvenv,代码行数:7,代码来源:command.py


示例2: read

 def read(self, filename):
   typecheck(filename, basestring)
   path = os.path.join(self.__path, filename)
   f = open(path, "rU")
   result = f.read()
   f.close()
   return result
开发者ID:sholiday,项目名称:cvenv,代码行数:7,代码来源:filesystem.py


示例3: build

  def build(self, action_runner):
    self.__lock.acquire()
    try:
      typecheck(action_runner, ActionRunner)

      while self.__num_pending > 0 and not self.failed:
        if len(self.__action_queue) == 0:
          # wait for actions
          # TODO(kenton):  Use a semaphore or something?
          self.__lock.release()
          try:
            time.sleep(1)
          finally:
            self.__lock.acquire()
          continue

        action_state = self.__action_queue.popleft()
        self.do_one_action(
            action_state.config, action_state.action, action_runner)
    except KeyboardInterrupt:
      if not self.failed:
        self.__console.write(ColoredText(ColoredText.RED, "INTERRUPTED"))
      self.failed = True
    except:
      self.failed = True
      raise
    finally:
      self.__lock.release()
开发者ID:sholiday,项目名称:cvenv,代码行数:28,代码来源:builder.py


示例4: _args_to_rules

def _args_to_rules(loader, args):
  """Given a list of command-line arguments like 'foo/bar.sebs:baz', return an
  iterator of rules which should be built."""

  typecheck(args, list, basestring)

  for arg in args:
    if arg.startswith("src/") or arg.startswith("src\\"):
      # For ease of use, we allow files to start with "src/", so tab completion
      # can be used.
      arg = arg[4:]
    elif arg.startswith("//"):
      # We also allow files to start with "//" which mimics to the syntax given
      # to sebs.import_.
      arg = arg[2:]
    print arg
    target = loader.load(arg)

    if isinstance(target, BuildFile):
      for name, value in target.__dict__.items():
        if isinstance(value, Rule):
          yield value
    elif not isinstance(target, Rule):
      raise UsageError("%s: Does not name a rule." % arg)
    else:
      yield target
开发者ID:sholiday,项目名称:cvenv,代码行数:26,代码来源:main.py


示例5: add_rule

  def add_rule(self, config, rule):
    typecheck(rule, Rule)

    rule.expand_once()

    for artifact in rule.outputs:
      self.add_artifact(config, artifact)
开发者ID:sholiday,项目名称:cvenv,代码行数:7,代码来源:builder.py


示例6: __init__

  def __init__(self, loader, context):
    typecheck(loader, Loader)
    typecheck(context, _ContextImpl)
    self.Rule = Rule
    self.Test = Test
    self.ArgumentSpec = ArgumentSpec
    self.Artifact = Artifact
    self.Action = Action
    self.DefinitionError = DefinitionError
    self.typecheck = typecheck

    self.Command            = command.Command
    self.EchoCommand        = command.EchoCommand
    self.EnvironmentCommand = command.EnvironmentCommand
    self.DoAllCommand       = command.DoAllCommand
    self.ConditionalCommand = command.ConditionalCommand
    self.SubprocessCommand  = command.SubprocessCommand
    self.DepFileCommand     = command.DepFileCommand
    self.MirrorCommand      = command.MirrorCommand

    self.__loader = loader
    self.__context = context
    parts = context.filename.rsplit("/", 1)
    if len(parts) == 1:
      self.__prefix = ""
    else:
      self.__prefix = parts[0] + "/"
开发者ID:sholiday,项目名称:cvenv,代码行数:27,代码来源:loader.py


示例7: mkdir

  def mkdir(self, filename):
    typecheck(filename, basestring)

    if filename in self.__files:
      raise os.error("Can't make directory because file exists: %s" % filename)
    if filename != "":
      self.mkdir(os.path.dirname(filename))
      self.__dirs.add(filename)
开发者ID:sholiday,项目名称:cvenv,代码行数:8,代码来源:filesystem.py


示例8: action_state

  def action_state(self, config, action):
    typecheck(action, Action)

    result = self.__actions.get((config, action))
    if result is None:
      result = _ActionState(action, config.root_dir, self, config)
      self.__actions[(config, action)] = result
    return result
开发者ID:sholiday,项目名称:cvenv,代码行数:8,代码来源:builder.py


示例9: touch

 def touch(self, filename, mtime=None):
   typecheck(filename, basestring)
   if filename not in self.__files:
     raise os.error("File not found: " + filename)
   if mtime is None:
     mtime = time.time()
   oldtime, content = self.__files[filename]
   self.__files[filename] = (mtime, content)
开发者ID:sholiday,项目名称:cvenv,代码行数:8,代码来源:filesystem.py


示例10: get_disk_path

  def get_disk_path(self, filename):
    """If the file is a real, on-disk file, return its path, suitable to be
    passed to open() or other file I/O routines.  If the file is not on disk,
    returns None.  The file does not necessarily have to actually exist; if it
    doesn't, this method will still return the path that the file would have
    if it did exist."""

    typecheck(filename, basestring)
    return None
开发者ID:sholiday,项目名称:cvenv,代码行数:9,代码来源:filesystem.py


示例11: action_state

  def action_state(self, action):
    typecheck(action, Action)

    result = self.__actions.get((action))
    if result is None:
      result = _ScriptActionState(action)
      action.command.write_script(_ScriptWriterImpl(result, self))
      self.__actions[(action)] = result
    return result
开发者ID:sholiday,项目名称:cvenv,代码行数:9,代码来源:script.py


示例12: source_artifact

  def source_artifact(self, filename):
    typecheck(filename, basestring)

    if filename in self.__source_artifacts:
      return self.__source_artifacts[filename]

    result = Artifact(filename, None)
    self.__source_artifacts[filename] = result
    return result
开发者ID:sholiday,项目名称:cvenv,代码行数:9,代码来源:loader.py


示例13: execfile

 def execfile(self, filename, globals):
   typecheck(filename, basestring)
   if filename not in self.__files:
     raise os.error("File not found: " + filename)
   (mtime, content) = self.__files[filename]
   # Can't just exec because we want the filename in tracebacks
   # to exactly match the filename parameter to this method.
   ast = compile(content, filename, "exec")
   exec ast in globals
开发者ID:sholiday,项目名称:cvenv,代码行数:9,代码来源:filesystem.py


示例14: __init__

  def __init__(self, state_map, config, action):
    typecheck(state_map, _StateMap)
    typecheck(action, Action)

    self.__state_map = state_map
    self.__config = config
    self.__action = action
    self.inputs = []
    self.outputs = []
    self.disk_inputs = []
开发者ID:sholiday,项目名称:cvenv,代码行数:10,代码来源:builder.py


示例15: intermediate_artifact

  def intermediate_artifact(self, filename, action, configured_name=None):
    self.__validate_artifact_name(filename, configured_name)
    typecheck(action, Action)

    if configured_name is not None:
      configured_name = ["tmp/%s/" % self.directory] + configured_name

    return self.__loader.derived_artifact(
      os.path.join("tmp", self.directory, filename), action,
      configured_name = configured_name)
开发者ID:sholiday,项目名称:cvenv,代码行数:10,代码来源:loader.py


示例16: add_artifact

  def add_artifact(self, config, artifact):
    typecheck(artifact, Artifact)

    artifact_state = self.__state_map.artifact_state(config, artifact)
    if not artifact_state.is_dirty:
      return   # Source file; nothing to do.

    # The artifact is dirty, therefore it must have an action.  Note that
    # artifact_state.artifact and artifact_state.config may differ from
    # the local artifact and config if the artifact is a reference to one
    # in another config.
    self.add_action(artifact_state.config, artifact_state.artifact.action)
开发者ID:sholiday,项目名称:cvenv,代码行数:12,代码来源:builder.py


示例17: __validate_artifact_name

  def __validate_artifact_name(self, filename, configured_name=None):
    typecheck(filename, basestring)
    normalized = os.path.normpath(filename).replace("\\", "/")
    if filename != normalized:
      raise DefinitionError(
        "File '%s' is not a normalized path name.  Please use '%s' "
        "instead." % (filename, normalized))

    if filename.startswith("../") or filename.startswith("/"):
      raise DefinitionError(
        "File '%s' points outside the surrounding directory.  To "
        "include a file from another directory, that directory must explicitly "
        "export it." % filename)
开发者ID:sholiday,项目名称:cvenv,代码行数:13,代码来源:loader.py


示例18: local_filename

  def local_filename(self, artifact):
    if isinstance(artifact, str):
      return artifact
    typecheck(artifact, Artifact)

    parts = artifact.filename.split("/")
    if parts[0] not in ["src", "tmp", "mem"]:
      return None

    parts = parts[1:]
    dir_parts = self.directory.split("/")
    if len(parts) < len(dir_parts) or parts[:len(dir_parts)] != dir_parts:
      return None
    return "/".join(parts[len(dir_parts):])
开发者ID:sholiday,项目名称:cvenv,代码行数:14,代码来源:loader.py


示例19: run

 def run(self, context, log):
   typecheck(context, CommandContext)
   value = context.read(self.__condition_artifact)
   if value == "true":
     return self.__true_command.run(context, log)
   elif value == "false":
     if self.__false_command is not None:
       return self.__false_command.run(context, log)
     else:
       return True
   else:
     log.write("Condition artifact was not true or false: %s\n" %
               self.__condition_artifact)
     return False
开发者ID:sholiday,项目名称:cvenv,代码行数:14,代码来源:command.py


示例20: derived_artifact

  def derived_artifact(self, filename, action, configured_name=None):
    typecheck(filename, basestring)
    typecheck(action, Action)

    if filename in self.__derived_artifacts:
      raise DefinitionError(
        "Two different rules claim to build file '%s'.  Conflicting rules are "
        "'%s' and '%s'." %
        (filename, action.rule.name,
         self.__derived_artifacts[filename].action.rule.name))

    filename = os.path.normpath(filename).replace("\\", "/")
    result = Artifact(filename, action, configured_name = configured_name)
    self.__derived_artifacts[filename] = result
    return result
开发者ID:sholiday,项目名称:cvenv,代码行数:15,代码来源:loader.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python requestbuilder.Requestobj类代码示例发布时间:2022-05-27
下一篇:
Python maindb.get_user函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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