當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。