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


Python errors.DistutilsOptionError方法代码示例

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


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

示例1: create_zipfile

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def create_zipfile(self, filename):
        zip_file = zipfile.ZipFile(filename, "w")
        try:
            self.mkpath(self.target_dir)  # just in case
            for root, dirs, files in os.walk(self.target_dir):
                if root == self.target_dir and not files:
                    raise DistutilsOptionError(
                        "no files found in upload directory '%s'"
                        % self.target_dir)
                for name in files:
                    full = os.path.join(root, name)
                    relative = root[len(self.target_dir):].lstrip(os.path.sep)
                    dest = os.path.join(relative, name)
                    zip_file.write(full, dest)
        finally:
            zip_file.close() 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:upload_docs.py

示例2: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):

        if self.test_suite and self.test_module:
            msg = "You may specify a module or a suite, but not both"
            raise DistutilsOptionError(msg)

        if self.test_suite is None:
            if self.test_module is None:
                self.test_suite = self.distribution.test_suite
            else:
                self.test_suite = self.test_module + ".test_suite"

        if self.test_loader is None:
            self.test_loader = getattr(self.distribution, 'test_loader', None)
        if self.test_loader is None:
            self.test_loader = "setuptools.command.test:ScanningLoader"
        if self.test_runner is None:
            self.test_runner = getattr(self.distribution, 'test_runner', None) 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:test.py

示例3: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        filenames = []
        if self.global_config:
            filenames.append(config_file('global'))
        if self.user_config:
            filenames.append(config_file('user'))
        if self.filename is not None:
            filenames.append(self.filename)
        if not filenames:
            filenames.append(config_file('local'))
        if len(filenames) > 1:
            raise DistutilsOptionError(
                "Must specify only one configuration file option",
                filenames
            )
        self.filename, = filenames 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:setopt.py

示例4: _parse_dict

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def _parse_dict(cls, value):
        """Represents value as a dict.

        :param value:
        :rtype: dict
        """
        separator = '='
        result = {}
        for line in cls._parse_list(value):
            key, sep, val = line.partition(separator)
            if sep != separator:
                raise DistutilsOptionError(
                    'Unable to parse option value to dict: %s' % value)
            result[key.strip()] = val.strip()

        return result 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:18,代码来源:config.py

示例5: parse

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def parse(self):
        """Parses configuration file items from one
        or more related sections.

        """
        for section_name, section_options in self.sections.items():

            method_postfix = ''
            if section_name:  # [section.option] variant
                method_postfix = '_%s' % section_name

            section_parser_method = getattr(
                self,
                # Dots in section names are tranlsated into dunderscores.
                ('parse_section%s' % method_postfix).replace('.', '__'),
                None)

            if section_parser_method is None:
                raise DistutilsOptionError(
                    'Unsupported distribution option section: [%s.%s]' % (
                        self.section_prefix, section_name))

            section_parser_method(section_options) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:25,代码来源:config.py

示例6: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        if self.match is None:
            raise DistutilsOptionError(
                "Must specify one or more (comma-separated) match patterns "
                "(e.g. '.zip' or '.egg')"
            )
        if self.keep is None:
            raise DistutilsOptionError("Must specify number of files to keep")
        try:
            self.keep = int(self.keep)
        except ValueError:
            raise DistutilsOptionError("--keep must be an integer")
        if isinstance(self.match, six.string_types):
            self.match = [
                convert_path(p.strip()) for p in self.match.split(',')
            ]
        self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:19,代码来源:rotate.py

示例7: debug_print

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def debug_print(self, msg):
        """Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        """
        from distutils.debug import DEBUG
        if DEBUG:
            print msg
            sys.stdout.flush()


    # -- Option validation methods -------------------------------------
    # (these are very handy in writing the 'finalize_options()' method)
    #
    # NB. the general philosophy here is to ensure that a particular option
    # value meets certain type and value constraints.  If not, we try to
    # force it into conformance (eg. if we expect a list but have a string,
    # split the string on comma and/or whitespace).  If we can't force the
    # option into conformance, raise DistutilsOptionError.  Thus, command
    # classes need do nothing more than (eg.)
    #   self.ensure_string_list('foo')
    # and they can be guaranteed that thereafter, self.foo will be
    # a list of strings. 
开发者ID:glmcdona,项目名称:meddle,代码行数:24,代码来源:cmd.py

示例8: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        self.set_undefined_options('build',
                                   ('build_lib', 'build_lib'),
                                   ('force', 'force'))

        # Get the distribution options that are aliases for build_py
        # options -- list of packages and list of modules.
        self.packages = self.distribution.packages
        self.py_modules = self.distribution.py_modules
        self.package_data = self.distribution.package_data
        self.package_dir = {}
        if self.distribution.package_dir:
            for name, path in self.distribution.package_dir.items():
                self.package_dir[name] = convert_path(path)
        self.data_files = self.get_data_files()

        # Ick, copied straight from install_lib.py (fancy_getopt needs a
        # type system!  Hell, *everything* needs a type system!!!)
        if not isinstance(self.optimize, int):
            try:
                self.optimize = int(self.optimize)
                assert 0 <= self.optimize <= 2
            except (ValueError, AssertionError):
                raise DistutilsOptionError("optimize must be 0, 1, or 2") 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:build_py.py

示例9: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        PyPIRCCommand.finalize_options(self)
        if self.identity and not self.sign:
            raise DistutilsOptionError(
                "Must use --sign for --identity to have meaning"
            )
        config = self._read_pypirc()
        if config != {}:
            self.username = config['username']
            self.password = config['password']
            self.repository = config['repository']
            self.realm = config['realm']

        # getting the password from the distribution
        # if previously set by the register command
        if not self.password and self.distribution.password:
            self.password = self.distribution.password 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:upload.py

示例10: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        # Get all the information we need to install pure Python modules
        # from the umbrella 'install' command -- build (source) directory,
        # install (target) directory, and whether to compile .py files.
        self.set_undefined_options('install',
                                   ('build_lib', 'build_dir'),
                                   ('install_lib', 'install_dir'),
                                   ('force', 'force'),
                                   ('compile', 'compile'),
                                   ('optimize', 'optimize'),
                                   ('skip_build', 'skip_build'),
                                  )

        if self.compile is None:
            self.compile = 1
        if self.optimize is None:
            self.optimize = 0

        if not isinstance(self.optimize, int):
            try:
                self.optimize = int(self.optimize)
                if self.optimize not in (0, 1, 2):
                    raise AssertionError
            except (ValueError, AssertionError):
                raise DistutilsOptionError, "optimize must be 0, 1, or 2" 
开发者ID:glmcdona,项目名称:meddle,代码行数:27,代码来源:install_lib.py

示例11: testUseFeatures

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def testUseFeatures(self):
        dist = self.dist
        self.assertEqual(dist.with_foo,1)
        self.assertEqual(dist.with_bar,0)
        self.assertEqual(dist.with_baz,1)
        self.assertTrue(not 'bar_et' in dist.py_modules)
        self.assertTrue(not 'pkg.bar' in dist.packages)
        self.assertTrue('pkg.baz' in dist.packages)
        self.assertTrue('scripts/baz_it' in dist.scripts)
        self.assertTrue(('libfoo','foo/foofoo.c') in dist.libraries)
        self.assertEqual(dist.ext_modules,[])
        self.assertEqual(dist.require_features, [self.req])

        # If we ask for bar, it should fail because we explicitly disabled
        # it on the command line
        self.assertRaises(DistutilsOptionError, dist.include_feature, 'bar') 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:18,代码来源:__init__.py

示例12: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):

        if self.test_suite is None:
            if self.test_module is None:
                self.test_suite = self.distribution.test_suite
            else:
                self.test_suite = self.test_module + ".test_suite"
        elif self.test_module:
            raise DistutilsOptionError(
                "You may specify a module or a suite, but not both"
            )

        self.test_args = [self.test_suite]

        if self.verbose:
            self.test_args.insert(0,'--verbose')
        if self.test_loader is None:
            self.test_loader = getattr(self.distribution, 'test_loader', None)
        if self.test_loader is None:
            self.test_loader = "setuptools.command.test:ScanningLoader"
        if self.test_runner is None:
            self.test_runner = getattr(self.distribution, 'test_runner', None) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:24,代码来源:test.py

示例13: finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def finalize_options(self):
        if self.match is None:
            raise DistutilsOptionError(
                "Must specify one or more (comma-separated) match patterns "
                "(e.g. '.zip' or '.egg')"
            )
        if self.keep is None:
            raise DistutilsOptionError("Must specify number of files to keep")
        try:
            self.keep = int(self.keep)
        except ValueError:
            raise DistutilsOptionError("--keep must be an integer")
        if isinstance(self.match, basestring):
            self.match = [
                convert_path(p.strip()) for p in self.match.split(',')
            ]
        self.set_undefined_options('bdist',('dist_dir', 'dist_dir')) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:19,代码来源:rotate.py

示例14: _resolve_setup_path

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def _resolve_setup_path(egg_base, install_dir, egg_path):
        """
        Generate a path from egg_base back to '.' where the
        setup script resides and ensure that path points to the
        setup path from $install_dir/$egg_path.
        """
        path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
        if path_to_setup != os.curdir:
            path_to_setup = '../' * (path_to_setup.count('/') + 1)
        resolved = normalize_path(
            os.path.join(install_dir, egg_path, path_to_setup)
        )
        if resolved != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", resolved, normalize_path(os.curdir))
        return path_to_setup 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:19,代码来源:develop.py

示例15: test_finalize_options

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsOptionError [as 别名]
def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = install_lib(dist)

        cmd.finalize_options()
        self.assertEqual(cmd.compile, 1)
        self.assertEqual(cmd.optimize, 0)

        # optimize must be 0, 1, or 2
        cmd.optimize = 'foo'
        self.assertRaises(DistutilsOptionError, cmd.finalize_options)
        cmd.optimize = '4'
        self.assertRaises(DistutilsOptionError, cmd.finalize_options)

        cmd.optimize = '2'
        cmd.finalize_options()
        self.assertEqual(cmd.optimize, 2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_install_lib.py


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