Exemple #1
0
    def _verify(self, val, project, recurse=True, vlog=None):
        if not val:
            if not self.optional:
                vlog.error('No file specified.')
            return

        if type(val) is not unicode:
            vlog.error('invalid type for %s: %s', self.name, type(val))
            return

        if len(self.extensions):
            ext_match = False
            for ext in self.extensions:
                if val.endswith(ext):
                    ext_match = True
                    break
            if not ext_match:
                vlog.error('invalid file type: %s', val)

        path = get_absolute_path(val, project.path)
        if not os.path.exists(path):
            vlog.error('file not exists: %s', path)

        if os.path.isdir(path):
            vlog.error('not a file: %s', path)
Exemple #2
0
    def _verify(self, val, project, recurse=True, vlog=None):
        if not val:
            if not self.optional:
                vlog.error('No file specified.')
            return

        if type(val) is not unicode:
            vlog.error('invalid type for %s: %s', self.name, type(val))
            return

        if len(self.extensions):
            ext_match = False
            for ext in self.extensions:
                if val.endswith(ext):
                    ext_match = True
                    break
            if not ext_match:
                vlog.error('invalid file type: %s', val)

        path = get_absolute_path(val, project.path)
        if not os.path.exists(path):
            vlog.error('file not exists: %s', path)

        if os.path.isdir(path):
            vlog.error('not a file: %s', path)
Exemple #3
0
    def _verify(self, val, project, recurse=True, vlog=None):
        if not val:
            if not self.optional:
                vlog.error('No folder specified.')
            return

        if type(val) is not unicode:
            vlog.error("Invalid type for %s: %s", self.name, type(val))
            return

        path = get_absolute_path(val, project.path)
        if not os.path.exists(path):
            vlog.error('Folder not exists: %s', path)
            return

        if not os.path.isdir(path):
            vlog.error('Not a folder: %s', path)
            return
Exemple #4
0
    def _verify(self, val, project, recurse=True, vlog=None):
        if not val:
            if not self.optional:
                vlog.error('No folder specified.')
            return

        if type(val) is not unicode:
            vlog.error("Invalid type for %s: %s", self.name, type(val))
            return

        path = get_absolute_path(val, project.path)
        if not os.path.exists(path):
            vlog.error('Folder not exists: %s', path)
            return

        if not os.path.isdir(path):
            vlog.error('Not a folder: %s', path)
            return
Exemple #5
0
def get_image_path(filename, project):
    # current
    if os.path.exists(filename):
        return filename

    if os.path.isabs(filename):
        return None

    # relative to project
    if project:
        path = get_absolute_path(filename, project.path)
        if os.path.exists(path):
            return path

    # res folder
    prefix = os.path.split(__file__)[0]
    path = os.path.join(prefix, "res", filename)
    if os.path.exists(path):
        return path

    return None
Exemple #6
0
def get_image_path(filename, project):
    # current
    if os.path.exists(filename):
        return filename

    if os.path.isabs(filename):
        return None

    # relative to project
    if project:
        path = get_absolute_path(filename, project.path)
        if os.path.exists(path):
            return path

    # res folder
    prefix = os.path.split(__file__)[0]
    path = os.path.join(prefix, 'res', filename)
    if os.path.exists(path):
        return path

    return None