当前位置: 首页>>代码示例>>Python>>正文


Python file.File方法代码示例

本文整理汇总了Python中file.File方法的典型用法代码示例。如果您正苦于以下问题:Python file.File方法的具体用法?Python file.File怎么用?Python file.File使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


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

示例1: add_files

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def add_files(self, files):
        """
        Add additional files to the task execution

        Should usually not be necessary. If you do some bad hacks with the bash you
        can add files that you transferred yourself to the project folders.

        Parameters
        ----------
        files : list of `File`
            the list of files to be added to the task

        """
        if isinstance(files, File):
            self._add_files.append(files)
        elif isinstance(files, (list, tuple)):
            self._add_files += files 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:19,代码来源:task.py

示例2: unstaged_input_files

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def unstaged_input_files(self):
        """
        Return a set of `File` objects that are used but are not part of the generator stage

        Usually a task requires some reused files from staging and specific others.
        This function lists all the files that this task will stage to its working directory
        but will not be available from the set of staged files of the tasks generator

        Returns
        -------
        set of `File`
            the set of `File` objects that are needed and not staged

        """
        staged = self.staged_files
        reqs = self.sources

        return {r for r in reqs if r.url not in staged} 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:20,代码来源:task.py

示例3: put

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def put(self, f, target):
        """
        Put a file back and make it persistent

        Corresponds to output_staging

        Parameters
        ----------
        f : `File`
            the file to be used
        target : str or `File`
            the target location. Need to contain a URL like `staging://` or
            `file://` for application side files

        Returns
        -------
        `Location`
            the actual target location

        """
        transaction = f.move(target)
        self.append(transaction)
        return transaction.target 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:25,代码来源:task.py

示例4: remove

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def remove(self, f):
        """
        Add an action to remove a file or folder

        Parameters
        ----------
        f : `File`
            the location to be removed

        Returns
        -------
        `Location`
            the actual location

        """
        transaction = f.remove()
        self.append(transaction)
        return transaction.source 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:20,代码来源:task.py

示例5: targets

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def targets(self):
        """
        Return a set of all new and overwritten files

        Returns
        -------
        set of `File`
            the list of files that are created or overwritten by this task
        """

        transactions = [t for t in self.script if isinstance(t, FileTransaction)]

        return filter(
            lambda x: not x.is_temp,
            set(sum(filter(bool, [f.added for f in transactions]), []) + self._add_files)) 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:17,代码来源:task.py

示例6: sources

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def sources(self):
        """
        Return a set of all required input files

        Returns
        -------
        set of `File`
            the list of files that are required by this task
        """
        transactions = [t for t in self.script if isinstance(t, FileTransaction)]

        return filter(
            lambda x: not x.is_temp,
            set(sum(filter(bool, [t.required for t in transactions]), []) + self._add_files)) 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:16,代码来源:task.py

示例7: new_files

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def new_files(self):
        """
        Return a set of all files the will be newly created by this task

        Returns
        -------
        set of `File`
            the set of files that are created by this task
        """

        outs = self.targets
        in_names = self.source_locations

        return {x for x in outs if x.url not in in_names} 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:16,代码来源:task.py

示例8: modified_files

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def modified_files(self):
        """
        A set of all input files whose names match output names and hence will be overwritten

        Returns
        -------
        list of `File`
            the list of potentially overwritten input files

        """
        ins = self.sources
        out_names = self.target_locations

        return {x for x in ins if x.url in out_names} 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:16,代码来源:task.py

示例9: get

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def get(self, f, name=None):
        """
        Get a file and make it available to the task in the main directory

        Parameters
        ----------
        f : `File`
        name : `Location` or str

        Returns
        -------
        `File`
            the file instance of the file to be created in the unit

        """
        if f.drive in ['staging', 'sandbox', 'shared']:
            transaction = f.link(name)
        elif f.drive == 'file':
            transaction = f.transfer(name)
        elif f.drive == 'worker':
            if name is None:
                return f
            else:
                transaction = f.copy(name)
        else:
            raise ValueError(
                'Weird file location `%s` not sure how to get it.' %
                f.location)

        self.append(transaction)

        assert isinstance(transaction, FileTransaction)
        return transaction.target 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:35,代码来源:task.py

示例10: __init__

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def __init__(self, generator=None):
        super(PythonTask, self).__init__(generator)

        self._python_import = None
        self._python_source_files = None
        self._python_function_name = None
        self._python_args = None
        self._python_kwargs = None

        # self.executable = 'python'
        # self.arguments = '_run_.py'

        self.then_func_name = 'then_func'

        self._rpc_input_file = \
            JSONFile('file://_rpc_input_%s.json' % hex(self.__uuid__))
        self._rpc_output_file = \
            JSONFile('file://_rpc_output_%s.json' % hex(self.__uuid__))

        # input args -> input.json
        self.pre.append(self._rpc_input_file.transfer('input.json'))

        # output args -> output.json
        self.post.append(File('output.json').transfer(self._rpc_output_file))

        f = File('staging:///_run_.py')
        self.pre.append(f.link())

        self.add_cb('success', self.__class__._cb_success)
        self.add_cb('submit', self.__class__._cb_submit)

        # if True the RPC result will be stored in the DB with the task
        self.store_output = True 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:35,代码来源:task.py

示例11: call

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def call(self, command, **kwargs):
        """
        Set the python function to be called with its arguments

        Parameters
        ----------
        command : function
            a python function defined inside a package or a function. If in a
            package then the package needs to be installed on the cluster to be
            called. A function defined in a local file can be called as long
            as dependencies are installed.
        kwargs : ``**kwargs``
            named arguments to the function

        """
        self._python_function_name = '.'.join([command.__module__, command.func_name])
        self._python_kwargs = kwargs

        self._python_import, self._python_source_files = \
            get_function_source(command)

        for f in self._python_source_files:
            self.pre.append(File('file://' + f).load().transfer())

        # call the helper script to execute the function call
        self.append('python _run_.py') 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:28,代码来源:task.py

示例12: files

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def files(self):
        return {
            key: value
            for key, value in self.items() if isinstance(value, File)} 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:6,代码来源:generator.py

示例13: stage

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def stage(self, obj, target=None):
        """
        Short cut to add a file to be staged

        Parameters
        ----------
        obj : `File`
            the file to be staged in the initial staging phase
        target : `Location` or str
            the (different) target name to be used

        """
        self.initial_staging.append(
            obj.transfer(target)
        ) 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:17,代码来源:generator.py

示例14: initialize

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def initialize(self, resource):
        """
        Initialize a project with a specific resource.

        Notes
        -----
        This should only be called to setup the project and only the very
        first time.

        Parameters
        ----------
        resource : `Resource`
            the resource used in this project

        """
        self.storage.close()

        self.resource = resource

        st = MongoDBStorage(self.name, 'w')
        # st.create_store(ObjectStore('objs', None))
        st.create_store(ObjectStore('generators', TaskGenerator))
        st.create_store(ObjectStore('files', File))
        st.create_store(ObjectStore('resources', Resource))
        st.create_store(ObjectStore('models', Model))
        st.create_store(ObjectStore('tasks', Task))
        st.create_store(ObjectStore('workers', Worker))
        st.create_store(ObjectStore('logs', LogEntry))
        st.create_store(FileStore('data', DataDict))
        # st.create_store(ObjectStore('commands', Command))

        st.save(self.resource)

        st.close()

        self._open_db() 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:38,代码来源:project.py

示例15: new_trajectory

# 需要导入模块: import file [as 别名]
# 或者: from file import File [as 别名]
def new_trajectory(self, frame, length, engine=None, number=1):
        """
        Convenience function to create a new `Trajectory` object

        It will use incrementing numbers to create trajectory names used in
        the engine executions. Use this function to always get an unused
        trajectory name.

        Parameters
        ----------
        frame : `File` or `Frame`
            if given a `File` it is assumed to be a ``.pdb`` file that contains
            initial coordinates. If a frame is given one assumes that this
            `Frame` is the initial structure / frame zero in this trajectory
        length : int
            the length of the trajectory
        engine : `Engine` or None
            the engine used to generate the trajectory. The engine contains all
            the specifics about the trajectory internal structure since it is the
            responsibility of the engine to really create the trajectory.
        number : int
            the number of trajectory objects to be returned. If ``1`` it will be
            a single object. Otherwise a list of `Trajectory` objects.

        Returns
        -------
        `Trajectory` or list of `Trajectory`

        """
        if number == 1:
            traj = Trajectory(next(self.traj_name), frame, length, engine)
            return traj

        elif number > 1:
            return [self.new_trajectory(frame, length, engine) for _ in range(number)] 
开发者ID:markovmodel,项目名称:adaptivemd,代码行数:37,代码来源:project.py


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