本文整理汇总了Python中sebs.helpers.typecheck函数的典型用法代码示例。如果您正苦于以下问题:Python typecheck函数的具体用法?Python typecheck怎么用?Python typecheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了typecheck函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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()
示例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
示例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)
示例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] + "/"
示例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)
示例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
示例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)
示例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
示例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
示例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
示例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
示例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 = []
示例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)