Ejemplo n.º 1
0
 def filesets(self):
     sets = []
     for directory in self.site_package_dirs:
         fileset = FileSet(directory, includes='**',
                           excludes=self.fileset_excludes)
         sets.append(fileset)
     return sets
Ejemplo n.º 2
0
 def test_calls_expand_fileset(self, expand_fileset_mock, source_fs):
     # pylint: disable=unused-argument,no-self-use,protected-access
     expand_fileset_mock.return_value = ()
     FileSet('/home/foo/src/bar-project',
             includes=['**'],
             excludes=['c*i.jpg'],
             followlinks=True)
     expand_fileset_mock.assert_called_with()
     assert expand_fileset_mock.call_count == 1
Ejemplo n.º 3
0
def fileset(source_fs):
    # pylint: disable=unused-argument,redefined-outer-name
    os.chdir('/home/foo/src/bar-project')
    return FileSet('/home/foo/src/bar-project',
                   includes=['**'],
                   excludes=[
                       'py-lambda-packer.yaml', '**/*.png', '**/*.html',
                       '**/config.*'
                   ],
                   followlinks=True)
Ejemplo n.º 4
0
 def test_calls_expand_glob(self, expand_glob_mock, source_fs):
     # pylint: disable=unused-argument,no-self-use,protected-access
     expand_glob_mock.return_value = []
     FileSet('/home/foo/src/bar-project',
             includes=['**'],
             excludes=['c*i.jpg'],
             followlinks=True)
     expand_glob_mock.assert_has_calls(
         [mock.call('**', True),
          mock.call('c*i.jpg', True)])
     assert expand_glob_mock.call_count == 2
Ejemplo n.º 5
0
def entry_point():
    # Only here to be quiet and dump out the config.  Have to do this before
    # activating logging.
    if '--generate-config' in sys.argv[1:]:
        Configuration.print_default_config()
        sys.exit(0)

    # General configuration
    setup_logging()
    cli_args = parse_args(sys.argv[1:])
    config = Configuration(vars(cli_args))
    cwd = os.getcwd()

    # Information for the VirtualEnv
    pip_requirements = config.data['virtualenv']['pip']['requirements']
    fileset_excludes = config.data['virtualenv']['default_excludes']

    # Information for the PyLambdaPacker
    filesets = []
    if config.data['packager']['includes']:
        filesets = [
            FileSet(cwd,
                    includes=config.data['packager']['includes'],
                    excludes=config.data['packager']['excludes'] +
                    config.data['packager']['default_excludes'])
        ]

    # Build!
    with VirtualEnv(python=config.data['virtualenv']['python'],
                    path=config.data['virtualenv']['path'],
                    keep=config.data['virtualenv']['keep'],
                    packages=config.data['virtualenv']['pip']['packages'],
                    requirements=pip_requirements,
                    fileset_excludes=fileset_excludes) as virtual_env, \
            Packager(
                zip_file=config.data['packager']['target'],
                build_path=config.data['packager']['build_path'],
                keep=config.data['packager']['keep']) as packager:

        packer = PyLambdaPacker(virtual_env, packager, filesets)
        packer.build()
Ejemplo n.º 6
0
 def test_include_exclude_all(self, source_fs):
     # pylint: disable=unused-argument,no-self-use,protected-access
     fileset = FileSet('/home/foo/src/bar-project', ['**'], ['**'])
     actual = fileset._expand_fileset()
     assert actual == ()
Ejemplo n.º 7
0
 def test_array_excludes(self, source_fs):
     # pylint: disable=unused-argument, no-self-use
     fileset = FileSet('', '**', ['*.html'])
     assert fileset.excludes == ('*.html', )
Ejemplo n.º 8
0
 def test_scalar_includes(self, source_fs):
     # pylint: disable=unused-argument, no-self-use
     fileset = FileSet('', '**')
     assert fileset.includes == ('**', )
Ejemplo n.º 9
0
 def test_none_includes(self, source_fs):
     # pylint: disable=unused-argument, no-self-use
     with pytest.raises(ValueError) as info:
         FileSet('', None)
     assert str(info.value) == '"includes" must be provided.'
Ejemplo n.º 10
0
 def test_blank_directory(self, source_fs):
     # pylint: disable=unused-argument, no-self-use
     fileset = FileSet('', ['**'])
     assert fileset.directory == '/'
Ejemplo n.º 11
0
 def test_none_directory(self, source_fs):
     # pylint: disable=unused-argument, no-self-use
     with pytest.raises(ValueError) as info:
         FileSet(None, ['**'])
     assert str(info.value) == \
         '"None" is not an acceptable "directory" value.'