コード例 #1
0
ファイル: create.py プロジェクト: Arturo0911/water-quality
    def inspect(self):
        """Inspect the current working diretory for a name and version.

        This information is harvested in where the directory is named
        like [name]-[version].
        """
        dir_name = os.path.basename(os.getcwd())
        self.data['name'] = dir_name
        match = re.match(r'(.*)-(\d.+)', dir_name)
        if match:
            self.data['name'] = match.group(1)
            self.data['version'] = match.group(2)
            # TODO needs testing!
            if not is_valid_version(self.data['version']):
                msg = "Invalid version discovered: %s" % self.data['version']
                raise ValueError(msg)
コード例 #2
0
ファイル: create.py プロジェクト: dstufft/distutils2
    def inspect(self):
        """Inspect the current working diretory for a name and version.

        This information is harvested in where the directory is named
        like [name]-[version].
        """
        dir_name = os.path.basename(os.getcwd())
        self.data['name'] = dir_name
        match = re.match(r'(.*)-(\d.+)', dir_name)
        if match:
            self.data['name'] = match.group(1)
            self.data['version'] = match.group(2)
            # TODO needs testing!
            if not is_valid_version(self.data['version']):
                msg = "Invalid version discovered: %s" % self.data['version']
                raise ValueError(msg)
コード例 #3
0
ファイル: metadata.py プロジェクト: Arturo0911/water-quality
    def set(self, name, value):
        """Control then set a metadata field."""
        name = self._convert_name(name)

        if ((name in _ELEMENTSFIELD or name == 'Platform')
                and not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = [v.strip() for v in value.split(',')]
            else:
                value = []
        elif (name in _LISTFIELDS and not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = [value]
            else:
                value = []

        if logger.isEnabledFor(logging.WARNING):
            project_name = self['Name']

            if name in _PREDICATE_FIELDS and value is not None:
                for v in value:
                    # check that the values are valid predicates
                    if not is_valid_predicate(v.split(';')[0]):
                        logger.warning(
                            '%r: %r is not a valid predicate (field %r)',
                            project_name, v, name)
            # FIXME this rejects UNKNOWN, is that right?
            elif name in _VERSIONS_FIELDS and value is not None:
                if not is_valid_versions(value):
                    logger.warning('%r: %r is not a valid version (field %r)',
                                   project_name, value, name)
            elif name in _VERSION_FIELDS and value is not None:
                if not is_valid_version(value):
                    logger.warning('%r: %r is not a valid version (field %r)',
                                   project_name, value, name)

        if name in _UNICODEFIELDS:
            if name == 'Description':
                value = self._remove_line_prefix(value)

        self._fields[name] = value
コード例 #4
0
ファイル: metadata.py プロジェクト: irslambouf/SyncServer
    def set(self, name, value):
        """Control then set a metadata field."""
        name = self._convert_name(name)

        if ((name in _ELEMENTSFIELD or name == 'Platform') and
            not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = [v.strip() for v in value.split(',')]
            else:
                value = []
        elif (name in _LISTFIELDS and
              not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = [value]
            else:
                value = []

        if name in _PREDICATE_FIELDS and value is not None:
            for v in value:
                # check that the values are valid predicates
                if not is_valid_predicate(v.split(';')[0]):
                    warn('"%s" is not a valid predicate (field "%s")' %
                         (v, name))
        # FIXME this rejects UNKNOWN, is that right?
        elif name in _VERSIONS_FIELDS and value is not None:
            if not is_valid_versions(value):
                warn('"%s" is not a valid version (field "%s")' %
                     (value, name))
        elif name in _VERSION_FIELDS and value is not None:
            if not is_valid_version(value):
                warn('"%s" is not a valid version (field "%s")' %
                     (value, name))

        if name in _UNICODEFIELDS:
            value = self._encode_field(value)
            if name == 'Description':
                value = self._remove_line_prefix(value)

        self._fields[name] = value
        self._set_best_version()
コード例 #5
0
ファイル: metadata.py プロジェクト: pombredanne/distutils2
    def set(self, name, value):
        """Control then set a metadata field."""
        name = self._convert_name(name)

        if (name in _ELEMENTSFIELD or name == "Platform") and not isinstance(value, (list, tuple)):
            if isinstance(value, basestring):
                value = [v.strip() for v in value.split(",")]
            else:
                value = []
        elif name in _LISTFIELDS and not isinstance(value, (list, tuple)):
            if isinstance(value, basestring):
                value = [value]
            else:
                value = []

        if logger.isEnabledFor(logging.WARNING):
            project_name = self["Name"]

            if name in _PREDICATE_FIELDS and value is not None:
                for v in value:
                    # check that the values are valid predicates
                    if not is_valid_predicate(v.split(";")[0]):
                        logger.warning("%r: %r is not a valid predicate (field %r)", project_name, v, name)
            # FIXME this rejects UNKNOWN, is that right?
            elif name in _VERSIONS_FIELDS and value is not None:
                if not is_valid_versions(value):
                    logger.warning("%r: %r is not a valid version (field %r)", project_name, value, name)
            elif name in _VERSION_FIELDS and value is not None:
                if not is_valid_version(value):
                    logger.warning("%r: %r is not a valid version (field %r)", project_name, value, name)

        if name in _UNICODEFIELDS:
            if name == "Description":
                value = self._remove_line_prefix(value)

        self._fields[name] = value
コード例 #6
0
ファイル: metadata.py プロジェクト: francescog/distutils2
    def set(self, name, value):
        """Controls then sets a metadata field"""
        name = self._convert_name(name)

        if (name in _ELEMENTSFIELD + ('Platform',) and
            not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = value.split(',')
            else:
                value = []
        elif (name in _LISTFIELDS and
            not isinstance(value, (list, tuple))):
            if isinstance(value, str):
                value = [value]
            else:
                value = None

        if name in _PREDICATE_FIELDS and value is not None:
            for v in value:
                # check that the values are valid predicates
                if not is_valid_predicate(v.split(';')[0]):
                    warn('"%s" is not a valid predicate' % v)
        elif name in _VERSIONS_FIELDS and value is not None:
            if not is_valid_versions(value):
                warn('"%s" is not a valid predicate' % value)
        elif name in _VERSION_FIELDS and value is not None:
            if not is_valid_version(value):
                warn('"%s" is not a valid version' % value)

        if name in _UNICODEFIELDS:
            value = self._encode_field(value)
            if name == 'Description':
                value = self._remove_line_prefix(value)

        self._fields[name] = value
        self._set_best_version()