示例#1
0
def has_metadata(context):
    """`<module_name>/__init__.py` with `__version__` and `__url__`"""
    init_path = '%s/__init__.py' % context.module_name
    has_metadata = (
        exists(init_path)
        and attributes.has_attribute(context.module_name, '__version__')
        and attributes.has_attribute(context.module_name, '__url__'))
    return report_and_raise(
        'Has module metadata', has_metadata,
        'Your %s/__init__.py must contain __version__ and __url__ attributes')
示例#2
0
def has_metadata(python_module):
    """`<module_name>/__init__.py` with `__version__` and `__url__`"""
    init_path = '{}/__init__.py'.format(python_module)
    has_metadata = (exists(init_path)
                    and attributes.has_attribute(python_module, '__version__')
                    and attributes.has_attribute(python_module, '__url__'))
    return report_and_raise(
        'Has module metadata',
        has_metadata,
        'Your %s/__init__.py must contain __version__ and __url__ attributes',
    )
示例#3
0
文件: probe.py 项目: YAmikep/changes
def has_metadata(context):
    """`<module_name>/__init__.py` with `__version__` and `__url__`"""
    init_path = '%s/__init__.py' % context.module_name
    has_metadata = (
        exists(init_path) and
        attributes.has_attribute(context.module_name, '__version__') and
        attributes.has_attribute(context.module_name, '__url__')
    )
    return report_and_raise(
        'Has module metadata',
        has_metadata,
        'Your %s/__init__.py must contain __version__ and __url__ attributes'
    )
示例#4
0
def has_metadata(python_module):
    """`<module_name>/__init__.py` with `__version__` and `__url__`"""
    init_path = '{}/__init__.py'.format(python_module)
    has_metadata = (
        exists(init_path)
        and attributes.has_attribute(python_module, '__version__')
        and attributes.has_attribute(python_module, '__url__')
    )
    return report_and_raise(
        'Has module metadata',
        has_metadata,
        'Your %s/__init__.py must contain __version__ and __url__ attributes',
    )
示例#5
0
 def test_has_attribute(self):
     self.assertTrue(
         attributes.has_attribute(
             self.module_name,
             '__version__'
         )
     )
示例#6
0
文件: probe.py 项目: Sureiya/changes
def probe_project(module_name):
    """
    Check if the project meets `changes` requirements
    """
    log.info('Checking project for changes requirements.')
    # on [github](https://github.com)
    git_remotes = sh.git.remote('-v')
    on_github = any(['github.com' in remote for remote in git_remotes])
    log.info('On Github? %s', on_github)

    # `setup.py`
    setup = exists('setup.py')
    log.info('setup.py? %s', setup)

    # `requirements.txt`
    requirements_file, requirements = get_requirements()
    has_requirements = exists(requirements_file)

    if has_requirements:
        # supports executing tests with `nosetests` or `tox`
        runs_tests = (
            has_requirement('nose') or has_requirement('tox')
        )
        log.info('Runs tests? %s' % runs_tests)

    # `CHANGELOG.md`
    has_changelog = exists('CHANGELOG.md')
    log.info('CHANGELOG.md? %s', has_changelog)

    # `<module_name>/__init__.py` with `__version__` and `__url__`
    init_path = '%s/__init__.py' % module_name
    has_metadata = (
        exists(init_path) and
        attributes.has_attribute(module_name, '__version__') and
        attributes.has_attribute(module_name, '__url__')
    )
    log.info('Has module metadata? %s', has_metadata)

    return (on_github and setup and has_changelog and has_metadata and
            has_requirements and runs_tests)
示例#7
0
def probe_project(module_name):
    """
    Check if the project meets `changes` requirements
    """
    log.info('Checking project for changes requirements.')
    # on [github](https://github.com)
    git_remotes = sh.git.remote('-v')
    on_github = any(['github.com' in remote for remote in git_remotes])
    log.info('On Github? %s', on_github)

    # `setup.py`
    setup = exists('setup.py')
    log.info('setup.py? %s', setup)

    # `requirements.txt`
    requirements_file, requirements = get_requirements()
    has_requirements = exists(requirements_file)

    if has_requirements:
        # supports executing tests with `nosetests` or `tox`
        runs_tests = (has_requirement('nose') or has_requirement('tox'))
        log.info('Runs tests? %s' % runs_tests)

    # `CHANGELOG.md`
    has_changelog = exists('CHANGELOG.md')
    log.info('CHANGELOG.md? %s', has_changelog)

    # `<module_name>/__init__.py` with `__version__` and `__url__`
    init_path = '%s/__init__.py' % module_name
    has_metadata = (exists(init_path)
                    and attributes.has_attribute(module_name, '__version__')
                    and attributes.has_attribute(module_name, '__url__'))
    log.info('Has module metadata? %s', has_metadata)

    return (on_github and setup and has_changelog and has_metadata
            and has_requirements and runs_tests)
示例#8
0
def test_has_attribute(python_module):
    assert attributes.has_attribute(context.module_name, '__version__')
示例#9
0
def test_has_attribute(python_module):
    assert attributes.has_attribute(context.module_name, '__version__')
示例#10
0
 def test_has_attribute(self):
     self.assertTrue(
         attributes.has_attribute(self.module_name, '__version__'))